/**
* StreamからStringに転換する
*
* @param inputHtml
* @return
* @throws IOException
*/
private String streamToString(InputStream inputHtml) throws IOException {
StringBuffer out = new StringBuffer();
byte[] b = new byte[4096];
for (int n; (n = inputHtml.read(b)) != -1;) {
out.append(new String(b, 0, n));
}
return out.toString();
}
* StreamからStringに転換する
*
* @param inputHtml
* @return
* @throws IOException
*/
private String streamToString(InputStream inputHtml) throws IOException {
StringBuffer out = new StringBuffer();
byte[] b = new byte[4096];
for (int n; (n = inputHtml.read(b)) != -1;) {
out.append(new String(b, 0, n));
}
return out.toString();
}
本文介绍了一种从InputStream读取数据并转换为String的方法。通过使用StringBuffer进行逐块拼接,最终形成完整的字符串内容。
3202

被折叠的 条评论
为什么被折叠?



