• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

File output

 
Wes Beere
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to output some text to a file using a FileWriter, but i cannot figure out how to begin a new line to add the next String of text to the file, cause the "\n" character didn't work... Please be something simple.
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Wes,
Welcome to JavaRanch!
"\n" is a specific character, the one used on UNIX to denote end of line. Other operating systems use other things; Windows uses the two characters "\r\n". The old Mac OS used just "\r"!
The PrintWriter class can help you abstract these differences away. Its "println" method contains logic that does the right thing for the local system -- println() sends the right line-ending characters for the local platform.
 
Wes Beere
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you. That was alot easier then i expected. One error out of the way, a coupla hundred more to go
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic