Results 1 to 3 of 3
- 12-17-2008, 02:43 AM #1
Member
- Join Date
- Dec 2008
- Posts
- 3
- Rep Power
- 0
How to open a file without erasing its contents?
I think what happening here is FileOutputStream is erasing the file and so when input.readObject() is called it's reading from a blank file. Is that right? Is there any way I can write to the file without recreating it? Maybe FileWriter?
input = new ObjectInputStream(new FileInputStream(dataFile));
output = new ObjectOutputStream(new FileOutputStream(dataFile));
table = (Table) input.readObject();
- 12-17-2008, 02:52 AM #2
Member
- Join Date
- Dec 2008
- Posts
- 3
- Rep Power
- 0
Okay, I just got it to work by switching around output = and table=
input = new ObjectInputStream(new FileInputStream(dataFile));
table = (Table) input.readObject();
output = new ObjectOutputStream(new FileOutputStream(dataFile));
...so this works fine. But is there a better way to do it?
-
Similar Threads
-
Writing to excel file erasing existing formatting
By jmHoekst in forum New To JavaReplies: 1Last Post: 09-16-2008, 06:58 PM -
seperation of file contents
By Ms.Ranjan in forum New To JavaReplies: 5Last Post: 07-11-2008, 10:17 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, 05:52 PM -
Viewing contents of zip file
By Java Tip in forum Java TipReplies: 0Last Post: 03-03-2008, 06:16 PM -
Viewing contents of JAR file
By Java Tip in forum Java TipReplies: 0Last Post: 12-21-2007, 04:12 PM
Bookmarks