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");
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");
本文介绍了一个在使用Java进行文件操作时遇到的问题:如何正确地在目标文件中插入换行符。作者最初尝试使用pw.writer(/n); 和 pw.write(/n/r); 进行换行,但均未成功。最终通过同事的帮助得知正确的换行写入方式为pw.write(/r/n);。
314

被折叠的 条评论
为什么被折叠?



