Results 1 to 6 of 6
Thread: How tor write into Existing File
- 08-17-2010, 12:22 PM #1
Member
- Join Date
- Aug 2010
- Posts
- 16
- Rep Power
- 0
How tor write into Existing File
Hello everybody, I have the txt file with data:
----------------------------------------------------------
Line number 0: This is the text test format for javaEdu folder
Line number 2:
Line number 3:
----------------------------------------------------------
Now I want to ADD the following: "Line number 4: testing Line 4"
I tried it like:
But this code does not add Line 4 but owerwrites test.txt. How can I add Line 4 into existing file without overwriting it???Java Code:import java.io.*; public class Buff3{ public static void main(String [] args) throws Exception{ String strFile="D:/javaEdu/test.txt"; BufferedWriter bos=null; try{ FileWriter fos=new FileWriter(strFile); bos =new BufferedWriter(fos); bos.write("Line 4: testing Line 4"); }finally{ if(bos!=null){ bos.flush(); bos.close(); } } } }
- 08-17-2010, 12:34 PM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,604
- Blog Entries
- 7
- Rep Power
- 17
- 08-17-2010, 12:55 PM #3
Member
- Join Date
- Aug 2010
- Posts
- 16
- Rep Power
- 0
- 08-17-2010, 12:57 PM #4
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,604
- Blog Entries
- 7
- Rep Power
- 17
Never try to program any Java without this.
kind regards,
Jos
- 08-17-2010, 01:02 PM #5
Member
- Join Date
- Aug 2010
- Posts
- 16
- Rep Power
- 0
Great THANKS!!!!
- 08-17-2010, 01:03 PM #6
Member
- Join Date
- Aug 2010
- Posts
- 16
- Rep Power
- 0
Similar Threads
-
how to write text on an existing image
By jeshmal4u in forum Java 2DReplies: 6Last Post: 05-07-2010, 06:14 PM -
How do I write to an existing file in Java with a program that asks for user input?
By gmoney8316 in forum New To JavaReplies: 13Last Post: 04-16-2010, 02:51 AM -
FileChooser checking for an existing file
By sky in forum AWT / SwingReplies: 4Last Post: 12-06-2009, 11:06 PM -
Changing Existing Zip file using java
By narayanan.1985 in forum Advanced JavaReplies: 1Last Post: 09-30-2009, 08:27 PM -
Run J2ME application using existing jar file
By chale in forum CLDC and MIDPReplies: 0Last Post: 08-25-2008, 02:11 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks