This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes File output Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "File output" Watch "File output" New topic
Author

File output

Wes Beere
Greenhorn

Joined: Oct 23, 2003
Posts: 5
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

Joined: Jul 08, 2003
Posts: 24183
    
  34

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.


[Jess in Action][AskingGoodQuestions]
Wes Beere
Greenhorn

Joined: Oct 23, 2003
Posts: 5
Thank you. That was alot easier then i expected. One error out of the way, a coupla hundred more to go
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: File output
 
Similar Threads
Problem with displaying output
Looking for utility program find strings..
write output to an xml file
help me the code
contents of dt.jar and tools.jar