Meaningless Drivel is fun!*
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 Android Security Essentials Live Lessons this week in the Android 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.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: Edit/Delete Objects from file
Similar Threads
Update Serializable Object
Log4j tracking
how can i count objects in an object file
Thread locks leading to lack of file handles
objects in a stream file