大道致遠
          前途漫漫
          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)  編輯  收藏

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


          網站導航:
           
          主站蜘蛛池模板: 澜沧| 左贡县| 宜宾县| 岳池县| 新巴尔虎左旗| 轮台县| 新余市| 临潭县| 浮山县| 彭泽县| 于都县| 九江县| 淮安市| 额济纳旗| 东平县| 衡阳市| 永嘉县| 许昌市| 聊城市| 扎兰屯市| 慈溪市| 岚皋县| 秭归县| 晋州市| 大竹县| 图们市| 洛川县| 广德县| 布尔津县| 贵溪市| 白水县| 巴林左旗| 宝丰县| 西乌| 武安市| 盱眙县| 富阳市| 临沭县| 上饶县| 枞阳县| 高州市|