Results 1 to 2 of 2
Thread: writing to an opened file..
- 02-23-2010, 08:11 PM #1
Member
- Join Date
- Feb 2010
- Posts
- 16
- Rep Power
- 0
writing to an opened file..
I need to open a file, get before the end of the file "\n" and write to the file... i am trying to do this this way...however i cant find how to write to the file.
Java Code:FileInputStream fstream = new FileInputStream("textfile.txt"); // Get the object of DataInputStream DataInputStream in = new DataInputStream(fstream); BufferedReader br = new BufferedReader(new InputStreamReader(in)); String strLine; //Read File Line By Line while ((strLine = br.readLine()) == null) { // write to file write(snapshotFiles[i]); } //Close the input stream in.close();
- 02-23-2010, 09:01 PM #2
Senior Member
- Join Date
- Dec 2009
- Location
- Belgrade, Serbia
- Posts
- 364
- Rep Power
- 4
FileWriterJava Code:java.io.FileWriter.FileWriter(String fileName, boolean append) throws IOException
public FileWriter(String fileName, boolean append) throws IOException
Constructs a FileWriter object given a file name with a boolean indicating whether or not to append the data written.
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.
Throws:
IOException - if the named file exists but is a directory rather than a regular file, does not exist but cannot be created, or cannot be opened for any other reason
--------------------------------------------------------------------------------
Similar Threads
-
Reading and Writing the contents of a file to another file
By priyankatxs in forum New To JavaReplies: 9Last Post: 10-20-2009, 10:52 AM -
[SOLVED] how to reading binary file and writing txt file
By tOpach in forum New To JavaReplies: 3Last Post: 05-09-2009, 11:31 PM -
swapping the contents of the file and writing to another file
By Ms.Ranjan in forum New To JavaReplies: 9Last Post: 07-10-2008, 04:52 PM -
Deleting a File that is opened
By ravian in forum Advanced JavaReplies: 6Last Post: 01-30-2008, 02:05 PM -
Reading an already opened file
By Java Tip in forum Java TipReplies: 0Last Post: 01-25-2008, 06:50 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks