This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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.
It is sorta covered in the JavaRanch Style Guide.
subject: Edit/Delete Objects from file
Similar Threads
Update Serializable Object
how can i count objects in an object file
Thread locks leading to lack of file handles
objects in a stream file
Log4j tracking