1. 程式人生 > >Java: PrintWriter.write 向文字檔案中寫入換行。

Java: PrintWriter.write 向文字檔案中寫入換行。

Today I use java to parse a file and get some special content and write the content to another file.
I met a strange problem that when I use pw.writer("/n"); to write a  newline, it failed. I also tried pw.write("/n/r"); but failed again.
I talked with my colleague and fine that:

if you want to write a new line to a plain-text document, the code must be like this:

pw.write("/r/n");