I need to serialize and deserialize a 3rd party object that has no default constructor and doesn't implement Serializable interface. What are my options?
Asked
Active
Viewed 231 times
0
-
3This is one option: http://stackoverflow.com/questions/6163872/how-to-serialize-a-non-serializable-in-java – Marko Topolnik Sep 14 '16 at 10:59
-
I can't make the field transient, because I need it to be part of the serialized object – Inna Gold Sep 14 '16 at 11:02
-
That's exactly what the answer is explaining, how to make the transient field a part of the serialized object. – Marko Topolnik Sep 14 '16 at 11:03
-
How can I "serialise the individual properties of your non-serialisable object"? Just copy them one by one to some other object that is serializable? – Inna Gold Sep 14 '16 at 11:06
-
Can you extend the object and implement Serializable? – Piotr Reszke Sep 14 '16 at 11:06
-
My guess would be to use the `ObjectOutputStream`'s methods. – Marko Topolnik Sep 14 '16 at 11:08
-
Yes, I can extend the class. – Inna Gold Sep 14 '16 at 11:21
-
Flagged as a duplicate question. That the answers may not provide a full solution, or you don't understand the answers, does not make the question a non-duplicate. If you have more details that sets this question apart, *update and improve your question*. – Martin Nyolt Sep 14 '16 at 11:30