How to implement serialization in java

Hi, I'm looking for any open source code available to implement class-best serialization.

I am talking about whether there is any open source (which is popular) that handles serialization better.

+3
source share
3 answers

Serialization is built into java. For most classes, you can simply implement java.io.Serializable, and your classes become magically serializable. Then you can use java.io.ObjectOutputStreamit java.io.ObjectInputStreamto read and write your objects.

If you require custom serialization, add the following methods to the class to override serialization behavior. They must match these signatures exactly :

private void writeObject(ObjectOutputStream out) throws IOException {
  //YOUR WRITE CODE HERE
}

private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
  // YOUR READ CODE HERE
}
+4

Java (, JDK, zippen src.zip), JBossSerialization, . , 6 6 , , , , .

+4

Are you looking for something like protobuf ? Like other commentators, it's hard for me to compromise your question, as originally written.

+2
source

Source: https://habr.com/ru/post/1795580/


All Articles