| Author |
printing a new line to file
|
jam hall
Greenhorn
Joined: Sep 06, 2005
Posts: 4
|
|
When using a PrintWriter object to print a report to file the \n(new line) control character doesn't seem to do anything but \t(tab) does. Is there another way to print a new line? Thanks ahead
|
 |
Ernest Friedman-Hill
author and iconoclast
Marshal
Joined: Jul 08, 2003
Posts: 24041
|
|
|
What's wrong with calling the println() method?
|
[Jess in Action][AskingGoodQuestions]
|
 |
Julien Grenier
Ranch Hand
Joined: Sep 01, 2005
Posts: 41
|
|
|
I'm guessing you are on windows. The newlines in windows are form with 2 caracters the \n and the \r so you need to write both like this \n\r to produce a new line.
|
 |
Layne Lund
Ranch Hand
Joined: Dec 06, 2001
Posts: 3061
|
|
Since the end-of-line sequence varies between different operating systems, you should use the following to make your program system-independent. Now the variable called newline contains the system-dependant end-of-line sequence. The Java API may have a static variable that serves the same purpose hiding somewhere, but I was unable to find it. HTH Layne
|
Java API Documentation
The Java Tutorial
|
 |
 |
|
|
subject: printing a new line to file
|
|
|