문제

Does anyone know how to make a nextline? Usually I use the "\n" characters but when I open the .txt I wrote, I see it didn't went to the nextline. Here's the code:

FileWriter f=new FileWriter(path);
f.write("bla bla \n");
f.write("bla bla");
도움이 되었습니까?

해결책

Wrap a BufferedWriter around it, which you should be doing anyway, and use BufferedWriter.newLine().

Or use a PrintWriter, but beware that it swallows exceptions.

If that doesn't solve your problem, use \r\n instead of just \n.

다른 팁

Try the following:

BufferedWriter f = new BufferedWriter(new FileWriter(path));
f.write("bla bla ");
f.newLine();
f.write("bla bla");
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top