This content has been marked as final. Show 3 replies
What does that even mean?
Serialisation is the process of converting an object (graph) to a stream of bytes. If you put those bytes into a persistent store (file/database/etc.) then they are persistent. If you don't, then they aren't.
I'll try to explain.
At present I serialize my object using:
However, I want the file on disk to 'delete on exit' if my application is killed or closes. Like it would if I had done:
FileOutputStream fos = null; ObjectOutputStream out = null; fos = new FileOutputStream(saveFileName); out = new ObjectOutputStream(fos); out.writeObject(myResult); out.close();
So, is it possible to serialize an object in this way?
File myFile = new File("xxxx"); myFile.createTempFile("yyy","zzz"); myFile.deleteOnExit();
This question is nothing at all to do with serialisation as far as I can make out.
Why can't you just use