public static void main(String[] args)
{
ByteBuffer b=ByteBuffer.wrap("hao rena ".getBytes());
ByteArrayInputStream bao=new ByteArrayInputStream(b.array());
try {
ObjectInputStream oop=new ObjectInputStream(bao);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
直接就报错:java.io.StreamCorruptedException: invalid stream header: 68616F20 这个怎么改呢?
{
ByteBuffer b=ByteBuffer.wrap("hao rena ".getBytes());
ByteArrayInputStream bao=new ByteArrayInputStream(b.array());
try {
ObjectInputStream oop=new ObjectInputStream(bao);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
直接就报错:java.io.StreamCorruptedException: invalid stream header: 68616F20 这个怎么改呢?
修改方式:
public static void main(String[] args)
{
ByteArrayInputStream bao=new ByteArrayInputStream();
ObjectOutputStream out=new ObjectOutputStream(bao);
out.writeObject("hao rena ");
try {
ObjectInputStream oop=new ObjectInputStream(bao); } catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}