将流中的数据保存到字符串中:
StringBuffer sb = new StringBuffer();
while (true) {
final int ch = is.read();
if (ch < 0) {
break;
} else {
sb.append((char)ch);
}
}
is.close();
}
将字符串转成流
InputStream is=(new StringReader(sb.toString());