//定义一个字节数组输出流
ByteArrayOutputStream os = new ByteArrayOutputStream();
//对象输出流
ObjectOutputStream out = new ObjectOutputStream(os);
//将对象写入到字节数组输出,进行序列化
out.writeObject(zhangcan);
byte[] zhangsanByte = os.toByteArray();
//字节数组输入流
ByteArrayInputStream is = new ByteArrayInputStream(zhangsanByte);
//只想反序列化,从流中读取对象
ObjectInputStream in = new ObjectInputStream(is);
Person person = (Person)in.readObject();
//使用Hessian进行序列化
ByteOutputStream os = new ByteOutputStream();
//Hessian 的序列化
HessianOutput ho = new HessianOutput(os);
ho.writeObject(zhangsan);
byte[] zhangsanByte = os.toByteArray();
ByteArrayInputStream is = new ByteArrayInputStream();
//Hessian的反序列化读取对象
HessianInput hi = new HessianInput();