Dedian  
          -- 關注搜索引擎的開發
          日歷
          <2006年4月>
          2627282930311
          2345678
          9101112131415
          16171819202122
          23242526272829
          30123456
          統計
          • 隨筆 - 82
          • 文章 - 2
          • 評論 - 228
          • 引用 - 0

          導航

          常用鏈接

          留言簿(8)

          隨筆分類(45)

          隨筆檔案(82)

          文章檔案(2)

          Java Spaces

          搜索

          •  

          積分與排名

          • 積分 - 65897
          • 排名 - 816

          最新評論

          閱讀排行榜

          評論排行榜

           
          1. String --> InputStream

          InputStream convertToInputStream(String str)
          {
          ??? ??? ByteArrayInputStream is = new ByteArrayInputStream(str.getBytes());
          ??????? return is;
          }

          2. InputStream --> String
          ????
          String convertToString(InputStream is)
          {
          ??? ??
          ?????? BufferedReader in = new BufferedReader(new InputStreamReader(is));
          ??? ??? StringBuffer buffer = new StringBuffer();
          ??? ??? String line = "";
          ??? ??? while ((line = in.readLine()) != null)
          ??? ??? {
          ???? ??? ??? buffer.append(line);
          ???? ??? }
          ???? ??? return buffer.toString();
          ??? ??? ???
          }

          When I do the socket programming, I always need to deal with inputstream and string, above are the basic ways to so that, but I am not sure if there are any simpler ways to do that...

          posted on 2006-04-29 05:17 Dedian 閱讀(630) 評論(3)  編輯  收藏 所屬分類: Java Memo
          評論:
          • # re: convertion between InputStream & String  zhangzhuang Posted @ 2006-09-05 15:11
            thank you!~  回復  更多評論   

          • # re: convertion between InputStream & String  http://www.bc-fermetures.fr Posted @ 2014-11-29 12:04
            BufferedReader in = new BufferedReader(new InputStreamReader(is));
            StringBuffer buffer = new StringBuffer();  回復  更多評論   

          • # re: convertion between InputStream & String  http://www.bc-fermetures.fr Posted @ 2014-12-04 11:06
            BufferedReader in = new BufferedReader(new InputStreamReader(is));
            StringBuffer buffer = new StringBuffer();  回復  更多評論   

           
          Copyright © Dedian Powered by: 博客園 模板提供:滬江博客
          主站蜘蛛池模板: 白山市| 六安市| 延庆县| 平舆县| 金门县| 东阳市| 宿迁市| 西乡县| 松溪县| 衡东县| 新河县| 苏尼特左旗| 海门市| 黔江区| 乐山市| 梓潼县| 离岛区| 东乡族自治县| 休宁县| 阿鲁科尔沁旗| 双城市| 涡阳县| 黄大仙区| 湘西| 安岳县| 许昌市| 滨海县| 保山市| 平度市| 伊吾县| 崇阳县| 晋州市| 遂平县| 蒲城县| 兴城市| 宿松县| 东阳市| 龙南县| 湘潭市| 昌邑市| 武夷山市|