在不同的平台上,换行符可能是不同的,例如:

  1. Mac平台:\r
  2. Unix或Linux:\n
  3. Windows或Http:\r\n
  4. Unicode标准:\u2028

所以当需要换行时,通常建议使用line.separator的系统属性:System.getProperty("line.separator");

不过如果你是在写一个网络程序或者服务器程序,则需要硬编码为"\r\n",而不管所选的平台。

相关文章:

  • 2022-12-23
  • 2022-01-08
  • 2022-01-15
  • 2021-07-28
  • 2022-12-23
  • 2021-11-27
猜你喜欢
  • 2021-09-22
  • 2022-12-23
  • 2021-07-05
  • 2021-10-18
  • 2021-11-04
  • 2022-12-23
相关资源
相似解决方案