Line separator in Java N/IO?

后端 未结 3 1432
[愿得一人]
[愿得一人] 2021-01-29 06:49

How do I insert new line when writing to a txt file using java.nio.file ? The following code produces a txt file with one line ABCDEF, instead of two s

3条回答
  •  无人及你
    2021-01-29 06:56

    Complementing to @Tunaki, if you want two lines, only insert another line:

    String test = "ABC" + System.lineSeparator() + System.lineSeparator() + "DEF";

提交回复
热议问题