|
-
Jul 23rd, 2003, 05:31 AM
#1
Thread Starter
New Member
Files writing to it again{resolved}
i have created a small three field form, and can save the data into a file using writeUTF, but once the program is closed, and then opened again and i write new data, the prev values of the file are washed?
i understand i need to append, but how?
thanks
Last edited by jframe; Jul 23rd, 2003 at 03:46 PM.
-
Jul 23rd, 2003, 10:06 AM
#2
Junior Member
try this:
FileOutputStream(File filename, boolean append)
if append is true, then it will write and the end of file, else overwrite.
Sincerely,
Neptune.
-
Jul 23rd, 2003, 12:38 PM
#3
Thread Starter
New Member
how will i make it true ? i didnt get ne idea...sorry about that..?
please help..thanks
-
Jul 23rd, 2003, 01:05 PM
#4
Dazed Member
If you would like to keep the path platform independent then you can use the following as an example.
Code:
FileWriter fw = new FileWriter("C:" + File.separator + "Java" + File.separator + "MyFiles" + File.separator +"Text.txt",true);
-
Jul 23rd, 2003, 01:09 PM
#5
Dazed Member
Also the only constructors that allows you the ability to append data to a file is FileWriter(String file, boolean append) and FileOutputStream(String file, boolean append). I don't know why Sun didnt add this functionality to the other constructors that allow you to pass in File objects.
-
Jul 23rd, 2003, 02:09 PM
#6
Thread Starter
New Member
FileOutputStream(somefile.dat, true append) ?
this is how?
i am really a freat at filing
-
Jul 23rd, 2003, 02:20 PM
#7
Dazed Member
Look at the previous code.
-
Jul 23rd, 2003, 02:29 PM
#8
Thread Starter
New Member
FileOutputStream(somefile.dat, true)
rite?
-
Jul 23rd, 2003, 02:31 PM
#9
Dazed Member
FileOutputStream fout = new FileOutputStream("C:" + File.separator "somefile.dat", true);
-
Jul 23rd, 2003, 02:48 PM
#10
Thread Starter
New Member
this is what i didnow
// File data = new File("somefile.dat"); //commented this out
and made this:..its working now 
ostream = new DataOutputStream(
new BufferedOutputStream(
new FileOutputStream("somefile.dat",true)));
Last edited by jframe; Jul 23rd, 2003 at 03:41 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|