File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Edit/Delete Objects from file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Edit/Delete Objects from file" Watch "Edit/Delete Objects from file" New topic

Edit/Delete Objects from file

Brian Cummins

Joined: Feb 24, 2005
Posts: 11
I was just wondering if there is any way of editing or deleting objects when they are read from a text file using the ObjectInputStream.
Stephen Huey
Ranch Hand

Joined: Jul 15, 2003
Posts: 618
Once you've read the Object out of the stream, you can do whatever you want with it. Take a look at how this guy reads a Dimension object out of the stream:

At that point, he could fiddle with the Dimension object however he wanted's in memory, just like all your other regular objects, so have at it!

Igor Stojanovic
Ranch Hand

Joined: Feb 18, 2005
Posts: 58
Thx Stephen for posting that link.

P.S. Do you have more links in your bookmarks like the first one?

kind regards
Brian Cummins

Joined: Feb 24, 2005
Posts: 11
Thanks for the advice. But can you actually overwrite that object in the file after editing.
I agree. Here's the link:
subject: Edit/Delete Objects from file
It's not a secret anymore!