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

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


          網站導航:
           
          主站蜘蛛池模板: 二连浩特市| 荔浦县| 大余县| 东乡| 成都市| 新干县| 谢通门县| 邵武市| 连江县| 柳河县| 旅游| 澄城县| 阿拉善左旗| 伊金霍洛旗| 敖汉旗| 大田县| 舟山市| 潜山县| 谷城县| 嘉祥县| 松滋市| 胶南市| 横峰县| 东至县| 奎屯市| 黑水县| 尖扎县| 桐柏县| 乌海市| 台南县| 绿春县| 宜章县| 肇源县| 永吉县| 丰宁| 莱芜市| 黔江区| 花莲县| 阳高县| 宿州市| 华容县|