开发者

how to write the newline character as a string to a file java

how can i write the newline 开发者_Python百科character as a string to a file java. For example i want to write the string to the file "hello\nworld" as it is to a file.

Thank you, Rana.


System.out.println("hello\\nworld");
System.out.println("hello\nworld");


Just a side note, you should be using System.getProperty("line.separator") rather than \n since this character is not always the system's line separator.


steven is right.

you can also retrieve a list of all properties by using following code:

System.getProperties().list(System.out);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜