Dear Chris
The trick is to concatenate streams:
PrintWriter fout = new PrintWriter(new FileWriter(outputFile));
// Write Records to File
fout.println("0,Alpha");
// New Record Required
fout.println("1,Beta");
fout.flush(); // ENSURE THE OUTPUT STREAM IS EMPTIED
fout.close();
IO is a bit of a pain in the arse in Java. Even simple stuff like this needs
a bit of thought! Definitely a limitation of the standard lib. The
flexibility is great, but at the expense of simplicity.
Nick.
-----Original Message-----
From: Jenkins, Christopher [mailto:[EMAIL PROTECTED]]
Sent: 30 August 2000 12:36
To: [EMAIL PROTECTED]
Subject: Simple file que - re EOL's
I'm using the following bit of code to write to a file, how do I start a new
record /line?
Secondly are there any methods avavilable to take comma delimited string and
build an array from it?
try
{
// Code to write to file
String outputFileName = File.separatorChar + "development" +
File.separatorChar + "build" +
File.separatorChar + "tomcat" +
File.separatorChar + "webapps" +
File.separatorChar + "examples" +
File.separatorChar + "list.txt";
File outputFile = new File(outputFileName);
FileWriter fout = new FileWriter(outputFile);
// Write Records to File
fout.write("0,Alpha");
// New Record Required
fout.write("1,Beta");
fout.close();
}catch(java.io.IOException e)
{
System.out.println(e.toString());
}
Chris J.
xt39096
e-mail:- jenkins, christopher
The Royal Bank of Scotland plc is registered in Scotland No 90312.
Registered Office: 36 St Andrew Square, Edinburgh EH2 2YB.
The Royal Bank of Scotland plc is regulated by IMRO, SFA and Personal
Investment Authority.
This e-mail message is confidential and for use by the addressee only. If
the message is received by anyone other than the addressee, please return
the message to the sender by replying to it and then delete the message from
your computer.
'Internet e-mails are not necessarily secure. The Royal Bank of Scotland plc
does not accept responsibility for changes made to this message after it was
sent.'
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
***************************************************************
The contents of this Email and any files transmitted with it
are confidential and intended solely for the use of the
individual or entity to whom it is addressed. The views stated
herein do not necessarily represent the view of the company.
If you are not the intended recipient of this Email you may not
copy, forward, disclose or otherwise use it or any part of it
in any form whatsoever. If you have received this mail in
error please Email the sender.
***************************************************************
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html