参考:http://tristan1.iteye.com/blo...
public void testdeserialize() throws ioexception, classnotfoundexception {
bytearrayoutputstream baos = new bytearrayoutputstream();
objectoutputstream oos = new objectoutputstream(baos);
biginteger bi = new biginteger(0);
oos.writeobject(bi); byte[] str = baos.tobytearray();
objectinputstream ois = new objectinputstream(new bufferedinputstream(new bytearrayinputstream(str)));
object obj = ois.readobject();
assertnotnull(obj);
assertequals(obj.getclass().getname(),java.math.biginteger);
assertequals(((biginteger)obj).intvalue(), 0);
}
关键处理
byte[] str = baos.tobytearray();