标签:
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 }
标签:
原文地址:http://www.cnblogs.com/hadis-yuki/p/4437082.html