只需要指定:

format.setNewLineAfterDeclaration(false);

即可。

例:

OutputFormat format = OutputFormat.createPrettyPrint();
format.setEncoding("UTF-8");
format.setNewLineAfterDeclaration(false);

这个方法的作用是设置声明之后换不换行的,默认是true,将其置为false即可。

相关文章:

  • 2022-12-23
  • 2021-12-13
  • 2022-01-03
  • 2021-10-28
  • 2022-12-23
  • 2022-01-10
  • 2021-06-06
  • 2021-12-13
猜你喜欢
  • 2022-12-23
  • 2021-10-13
  • 2022-12-23
  • 2021-07-19
  • 2021-07-15
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案