Get your CodeRanch badge!*
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 Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Edit/Delete Objects from file" Watch "Edit/Delete Objects from file" New topic
Author

Edit/Delete Objects from file

Brian Cummins
Greenhorn

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:
http://home.tiscali.nl/~bmc88/java/sbook/041.html

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

Overview:
http://java.sun.com/j2se/1.4.2/docs/api/java/io/ObjectInputStream.html
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
Igor
Brian Cummins
Greenhorn

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: http://aspose.com/file-tools
 
subject: Edit/Delete Objects from file
 
Similar Threads
objects in a stream file
Thread locks leading to lack of file handles
Log4j tracking
how can i count objects in an object file
Update Serializable Object