| Author |
New Line in Java?
|
Andy Boyd
Greenhorn
Joined: Feb 02, 2004
Posts: 5
|
|
Hello all, I am new to java and have a question about file output. I am using the filewriter to access a basic text document. I am writing out short strings and would like each one on a new line but they are just being concatenated into one large string. I would like to be able to get my output to go on to a new line each time I write to the file. Any help? Thanks
|
 |
Ernest Friedman-Hill
author and iconoclast
Marshal
Joined: Jul 08, 2003
Posts: 24045
|
|
Hi, Welcome to JavaRanch! Perhaps the easiest thing to do looks like this:
|
[Jess in Action][AskingGoodQuestions]
|
 |
Sadanand Murthy
Ranch Hand
Joined: Nov 26, 2003
Posts: 382
|
|
Look at the documentation for PrintWriter. It has a method called print() which will print and stay at that line. So the next call to print() or println() will print on the same line. Another method called println() will print and terminate that line. So the next call to print() or println() will automatically print on a new line.
|
Ever Existing, Ever Conscious, Ever-new Bliss
|
 |
Andy Boyd
Greenhorn
Joined: Feb 02, 2004
Posts: 5
|
|
|
Thanks a lot. The Print Writer method worked great.
|
 |
 |
|
|
subject: New Line in Java?
|
|
|