A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
Take Control of Upgrading to Yosemite
Take Control of Automating Your Mac
this week in the
File writing 1 line at a time
Joined: Jun 05, 2001
Dec 08, 2005 08:37:00
How can I set up an output file and and write so each write goes on a
Joined: Feb 07, 2005
Dec 08, 2005 08:42:00
You can create an external text file with
writer = new
where fileName is the name of the file you want to create.
Be careful. With this constructor of
, if the file already exists, it will be overwritten.
Then you can wrap it in a
output = new
and then to write a line to the file and include a newline in the output, you would use
Make sure that you close the
so that any text buffered in memory is written to the file.
author and iconoclast
Joined: Jul 08, 2003
Dec 08, 2005 08:43:00
This code is for JDK 1.5:
String lines = ... PrintWriter pw = new PrintWriter(filename); for (String line: lines) pw.println(line); pw.close();
[Jess in Action]
subject: File writing 1 line at a time
adding a newline character to a file using fileoutputstream
File Input Stream
VBScript to compare files... not really working
I am new to JSP , what is <%@ taglib ?
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014