「Java初心者」javaでストリームを読む処理サンプルコード
Javaコード
public static String readTextInputStream(InputStream is) throws IOException {
StringBuffer strbuffer = new StringBuffer();
String line;
BufferedReader reader = null;
try {
reader = new BufferedReader(new InputStreamReader(is));
while ((line = reader.readLine()) != null) {
strbuffer.append(line).append(“\r\n");
}
} finally {
if (reader != null) {
reader.close();
}
}
return strbuffer.toString();
}