Dedian |
|
|||
-- 關(guān)注搜索引擎的開發(fā) |
日歷
統(tǒng)計(jì)
導(dǎo)航常用鏈接留言簿(8)隨筆分類(45)
隨筆檔案(82)
文章檔案(2)Java Spaces搜索積分與排名
最新評論
閱讀排行榜評論排行榜 |
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...
評論:
|
![]() |
|
Copyright © Dedian | Powered by: 博客園 模板提供:滬江博客 |