how to transform an object into an array of bytes on Java!
hello
I have an Object a and I wanna be able to save it's state on a random access file. I've learned that in order to write on a file I ne ed to transform it into a byte array. But how can I do it? is there something like a.tobyteArray() ??? once that I've saved it, how can I retreive it for future use? Thanks thanks thanks a lot! |
Have you looked into the 'serializeable' interface? It might do what you want, it allows you to save objects and restore them later.
-Josh |
This code does what you want... you should read the sun docs on the ObjectOutputStream object here: http://java.sun.com/j2se/1.4.1/docs/...putStream.html
Code:
HTH B. |
thanks a lot! that's exactly what I was looking for. Thanks!
|
All times are GMT -5. The time now is 12:00 PM. |