大道致遠
          前途漫漫
          posts - 4,comments - 0,trackbacks - 0

          //Client 端:
          ??Student pgt=new Student();
          ??pgt.setName("name");
          ??pgt.setAge("age");
          ??ByteArrayOutputStream baos = new ByteArrayOutputStream();
          ??ObjectOutputStream oos = new ObjectOutputStream(baos);
          ??oos.writeObject(pgt);
          ??oos.close();
          ??byte[] bs = baos.toByteArray();
          ??ByteBuffer buffer = ByteBuffer.wrap(bs, 0, bs.length);
          ??
          ??? while (buffer.hasRemaining() & client.write(buffer) != -1)
          ??? {
          ?????? waitFor(1000);
          ??? }
          ??? buffer.flip();

          //Server 端:
          ?????? int reads = sc_key.read(byteBuffer);
          ?????? byteBuffer.flip();
          ?????? byte[] tmp_buffer = byteBuffer.array();
          ?????? ByteArrayInputStream byteIn = new ByteArrayInputStream(tmp_buffer);
          ?????? ObjectInputStream objIn = new ObjectInputStream(byteIn);
          ?????? pgt = (Student) objIn.readObject();
          ?????? objIn.close();

          posted on 2007-01-31 15:08 wyg405 閱讀(992) 評論(0)  編輯  收藏

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 永州市| 云浮市| 永定县| 昌平区| 潮安县| 新民市| 双柏县| 安乡县| 全椒县| 乌苏市| 天全县| 海门市| 五常市| 鞍山市| 资中县| 营山县| 新乡市| 米易县| 三穗县| 县级市| 子洲县| 弥渡县| 望城县| 钟祥市| 洪泽县| 清镇市| 抚松县| 和顺县| 梁平县| 曲麻莱县| 工布江达县| 台前县| 买车| 双鸭山市| 台山市| 吴旗县| 班玛县| 玛曲县| 巴马| 石泉县| 沧源|