我们有这个对象,需要通过套接字发送:
static class Msg implements Serializable {
int num;
String name;
boolean [] sign;
//modify 'Message' to 'Msg'....
public Msg( int num, String name,boolean[] sign) {
super();
this.num=num;
this.name=name;
this.sign=sign;
Myarraycopy(this.sign,sign);
}
public boolean[] getsign() {
return sign
}
// Some methods
}
但是在代码的其他部分。
Socket _socket;
一边
ObjectOutputStream out = new ObjectOutputStream(_socket.getOutputStream());
Msg senMsg = new Msg(3,"Fine", new boolean[]{true,true,true})
out.writeObject(senMsg);
...................在另一边
ObjectInputStream in = new ObjectInputStream(_socket.getInputStream());
Msg recMsg = (Msg) in.readObject();
boolean[] s = recMsg.getsign();
System.out.println(s[0]+", "+ s[1]", "+s[2]);
为什么输出是:假,假,假。
如何从 ObjectInputStream 中检索数组的值;