大道致遠(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 閱讀(989) 評(píng)論(0)  編輯  收藏

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


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 尼勒克县| 德阳市| 黄大仙区| 开封县| 枝江市| 五常市| 亚东县| 富裕县| 常宁市| 清涧县| 新营市| 新昌县| 安乡县| 新津县| 奇台县| 邢台市| 清苑县| 固安县| 大名县| 新竹县| 府谷县| 梁平县| 宿迁市| 应用必备| 太原市| 台北市| 揭阳市| 大田县| 体育| 尼勒克县| 云阳县| 西乌珠穆沁旗| 宝坻区| 驻马店市| 黔西| 舒兰市| 封丘县| 和平县| 子长县| 平顺县| 繁昌县|