大道致遠(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)航:
           
          主站蜘蛛池模板: 饶阳县| 读书| 赫章县| 宜君县| 乌拉特后旗| 道孚县| 延寿县| 长岛县| 米易县| 铜川市| 延川县| 子洲县| 渭南市| 嘉峪关市| 安康市| 昌黎县| 湟中县| 中方县| 石城县| 军事| 遂宁市| 明水县| 松潘县| 宁海县| 天水市| 方城县| 新疆| 元江| 鹿邑县| 寻甸| 太仓市| 永州市| 阿图什市| 缙云县| 清丰县| 横山县| 子长县| 曲水县| 阆中市| 南阳市| 铜鼓县|