大道致遠(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) 評論(0)  編輯  收藏

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


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 武鸣县| 星子县| 东乌珠穆沁旗| 保亭| 陕西省| 阜南县| 安图县| 定边县| 西充县| 卓资县| 若尔盖县| 巴里| 杨浦区| 巫溪县| 博客| 河北区| 汕头市| 久治县| 娄烦县| 满城县| 中宁县| 武宣县| 宝兴县| 玉山县| 武邑县| 永平县| 樟树市| 西城区| 兴安县| 黄浦区| 石屏县| 东方市| 临汾市| 炎陵县| 普洱| 博白县| 车致| 宜阳县| 乐业县| 乐山市| 永和县|