Results 1 to 3 of 3
Thread: Start write at the eol.
- 09-26-2009, 09:18 AM #1
Senior Member
- Join Date
- Sep 2009
- Location
- Sweden/Borås
- Posts
- 107
- Rep Power
- 0
Start write at the eol.
Hello!
Newbi have a small problem, I Have searched sun´s doc but can´t find what i need.
This is the code.
What this does is read the file, and write the new input to readme.txt. BUT i want it to start write at the end of line. And not write over the old text as it does now. thank´s for any help.Java Code:// Read the file try { BufferedReader in = new BufferedReader(new InputStreamReader (new FileInputStream("c:/java/readme.txt"))); String str; while ((str = in.readLine()) != null) { System.out.println(str); } in.close(); }catch (IOException e) { e.printStackTrace(); } // End of Read the file //Write the input to file! try { Writer out = new OutputStreamWriter(new FileOutputStream("c:/java/readme.txt")); out.write(aTextField.getText()); out.close(); } catch (IOException e) { e.printStackTrace(); } // End of write }}}
/ocean
- 09-26-2009, 10:47 AM #2
Senior Member
- Join Date
- Aug 2008
- Posts
- 384
- Rep Power
- 5
Have a look at the FileWriter class:
FileWriter (Java 2 Platform SE v1.4.2)I die a little on the inside...
Every time I get shot.
- 09-26-2009, 12:13 PM #3
Senior Member
- Join Date
- Sep 2009
- Location
- Sweden/Borås
- Posts
- 107
- Rep Power
- 0
A very big thank´s Supamagier. Found .
"public FileWriter(String fileName,
boolean append)
throws IOException
Parameters:
fileName - String The system-dependent filename.
append - boolean if true, then data will be written to the end of the file rather than the beginning.
And that made me do this.
EDIT : btw how do i mark this "solved"?Java Code:private boolean append ;<------ try { Writer out = new OutputStreamWriter(new FileOutputStream("c:/java/readme.txt",append = true));<------ out.write(aTextField.getText()); out.close(); } catch (IOException e) { e.printStackTrace(); // End of writeLast edited by ocean; 09-26-2009 at 12:20 PM.
Similar Threads
-
How do you start a Java program from the "Start" menu under Windows?
By ScottVal in forum New To JavaReplies: 5Last Post: 03-20-2009, 10:04 PM -
Where to start?
By McChill in forum New To JavaReplies: 5Last Post: 02-19-2009, 02:26 PM -
Web Start
By DannyZB in forum NetBeansReplies: 0Last Post: 11-14-2008, 12:58 PM -
How to start
By sand.softnet1 in forum New To JavaReplies: 5Last Post: 09-05-2008, 07:41 PM -
How to start
By cachi in forum Java AppletsReplies: 1Last Post: 08-06-2007, 08:43 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks