Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

write newline(\n) back to file  RSS feed

 
Ji Li
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using the following to write back a text file.

------------------------------------
dataOut.writeBytes("Baldwin\n");
dataOut.writeBytes("Baldwin\n");
------------------------------------
, but when I ckeck the output file, the NEWLINE(\n) doesn't work. The result is "BaldwinBaldwin". What wrong with it? How to write in new-line?

Thank all - li
 
Albert Gan
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
String separator = System.getProperty("line.separator");
dataOut.writeBytes("Baldwin" + separator);
dataOut.writeBytes("Baldwin" + separator);

will this do ?

good luck to you ^^
 
Ji Li
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Albert Gan

Thanks your words - li
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!