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);
精彩评论