大道致遠(yuǎn)
          前途漫漫
          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) 評(píng)論(0)  編輯  收藏

          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 辉县市| 郧西县| 南昌市| 滦平县| 天水市| 胶南市| 绵阳市| 黄骅市| 崇明县| 偃师市| 平原县| 安溪县| 新泰市| 黑河市| 绍兴县| 牡丹江市| 灌云县| 东港市| 赤峰市| 金湖县| 浑源县| 卓尼县| 古蔺县| 沂水县| 克什克腾旗| 苍溪县| 三河市| 昭平县| 报价| 垫江县| 南宫市| 新兴县| 广平县| 济南市| 双流县| 通海县| 湾仔区| 巴彦县| 怀化市| 大埔县| 云梦县|