1 public byte[] write(Serializable object) throws IOException {
 2         ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
 3         ObjectOutputStream stream = new ObjectOutputStream(byteArrayOutputStream);
 4         stream.writeObject(object);
 5         return byteArrayOutputStream.toByteArray();
 6     }
 7 
 8     public Object read(byte[] data) throws IOException, ClassNotFoundException {
 9         ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(data);
10         ObjectInputStream inputStream = new ObjectInputStream(byteArrayInputStream);
11         return inputStream.readObject();
12     }

 

相关文章:

  • 2021-11-16
  • 2022-12-23
  • 2022-01-22
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-16
  • 2021-09-30
猜你喜欢
  • 2021-08-15
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案