File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes writing a newline char into a text file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "writing a newline char into a text file" Watch "writing a newline char into a text file" New topic

writing a newline char into a text file

samuel higgins

Joined: Apr 21, 2003
Posts: 1
using the FileWriter class, how to you write a newline into a text file? I tried \n but in the text file i just get a little black box.
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Wrap the FileWriter in a BufferedWriter and use the newLine() method. Something like this:

[ April 21, 2003: Message edited by: Michael Morris ]

Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
Francis Siu
Ranch Hand

Joined: Jan 04, 2003
Posts: 867
hi samuel
I have another method/suggestion to reference

I hope that I can answer your question
if you want to append the text to the text file
please post a message again

Francis Siu
I agree. Here's the link:
subject: writing a newline char into a text file
It's not a secret anymore!