Reliably convert any object to String and then back again

后端 未结 7 756
名媛妹妹
名媛妹妹 2020-12-02 13:35

Is there a reliable way to convert any object to a String and then back again to the same Object? I\'ve seen some examples of people converting them using toString()

相关标签:
7条回答
  • None will work in all cases. An object may, e.g., contain references to other JVMs handling their state, and this state may be not available for you to restore.

    Additional problems you're going to meet will include open streams, listening sockets, and almost anything else from the outer world.

    There's no need to repeat that most at least two of Java core engineers say that serialization was one of the greatest mistakes a single worst feature in Java, that is, after finalization. (I do love serialization nevertheless, it's handy. But it won't always work.)

    0 讨论(0)
提交回复
热议问题