你是用串行化對象吧?
把對象寫到流中
ByteArrayOutputStream bo = new ByteArrayOutputStream();
ObjectOutputStream oo = new ObjectOutputStream(bo);
oo.writeObject(YourClass);用Socket傳到客戶端後﹐讀出對象
ByteArrayInputStream bi = new ByteArrayInputStream(to.toByteArray());
ObjectInputStream oi = new ObjectInputStream(bi);
YourClassType YourClass = (YourClassType)oi.readObject();
把對象寫到流中
ByteArrayOutputStream bo = new ByteArrayOutputStream();
ObjectOutputStream oo = new ObjectOutputStream(bo);
oo.writeObject(YourClass);用Socket傳到客戶端後﹐讀出對象
ByteArrayInputStream bi = new ByteArrayInputStream(to.toByteArray());
ObjectInputStream oi = new ObjectInputStream(bi);
YourClassType YourClass = (YourClassType)oi.readObject();
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货