我正在尝试测试一个程序,为此我需要访问 ReadExternal 函数,但我在 ObjectInputStream 上遇到 StreamCorrupted 异常。我知道我需要使用由 WriteObject 编写的对象,但不知道该怎么做......
ObjectOutputStream out=new ObjectOutputStream(new ByteArrayOutputStream());
out.writeObject(ss3);
ss3.writeExternal(out);
try{
ByteInputStream bi=new ByteInputStream();
bi.setBuf(bb);
out.write(bb);
ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(bb));
String s1=(String) in.readObject();
}
catch(Exception e){
e.printStackTrace();
}