[prog] Java I/O problem 2

Sue Stones suzo at spin.net.au
Mon Apr 18 11:40:27 EST 2005


Noir wrote:

>>I can read the file and get the output (STDOUT). But
>>how am I going to break it down into new lines?
> 
> 
> 
> My code looks like this:

I was just writing a reply when your second email arrived, by which I 
think you mean that you have solved the problem that you were asking 
about.  If not can you be more specific.

> 		System.out.println(record + "\n"); 

I will point put one thing about this line.  You are printing *2 
newlines* for every record.  Not that there is anything wrong with that 
if its what you want, but understanding how is important.

1) the string "\n" gives one new line
2) println is short for "print line" meaning that what comes after it is 
everything on that line, so terminate it with a new line.

To get the data on consecutive lines (like the desired output that you 
mentioned use EITHER:

		System.out.print(record + "\n");
		System.out.println(record);

In most situations the second one would be preferred.

sue





More information about the Programming mailing list