importcn.hutool.core.util.ObjectUtil;
importjava.io.Serializable;
importjava.util.Arrays;
publicclassTest {
publicstaticvoidmain(String[] args) {
Dogdog=newDog("hoho");
byte[] serialize=ObjectUtil.serialize(dog);
System.out.println(Arrays.toString(serialize));
dog=ObjectUtil.deserialize(serialize);
System.out.println(dog.toString());
}
staticclassDogimplementsSerializable {
Stringname;
publicDog(Stringname) {
this.name=name;
}
@OverridepublicStringtoString() {
return"Dog{"+"name='"+name+'\''+'}';
}
}
}