A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
video training course this week in the
printing a new line to file
Joined: Sep 06, 2005
Sep 12, 2005 05:24:00
When using a
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?
author and iconoclast
Joined: Jul 08, 2003
Sep 12, 2005 05:35:00
What's wrong with calling the println() method?
[Jess in Action]
Joined: Sep 01, 2005
Sep 12, 2005 12:21:00
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.
Joined: Dec 06, 2001
Sep 12, 2005 13:04:00
Since the end-of-line sequence varies between different operating systems, you should use the following to make your program system-independent.
String newline = System.getProperty("line.separator");
Now the variable called newline contains the system-dependant end-of-line sequence. The
API may have a static variable that serves the same purpose hiding somewhere, but I was unable to find it.
Java API Documentation
The Java Tutorial
I agree. Here's the link:
subject: printing a new line to file
system.out.print vs println
SCJP Brainteaser (11)
printing new line in file
Problem in reading empty line
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015