Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to delete an object which is seraliazed from the file

 
Ashuthosh san
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am writing some objects to file using writeObject(), and after reading using readObject() i want to delete that object from that file.
Could you please let me know how do i do it?

I want to delete those objects from the file once i am read.

Regards
Asha

 
amit punekar
Ranch Hand
Posts: 544
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I think you are writing the object's state using ObjectOutputStream that has handle to FileOutputStream. If that is the case you can delete the file in which the object was serialized using java.io.File.
Hope this helps.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic