Skip to content

Instantly share code, notes, and snippets.

@narita1980
Created June 15, 2012 07:18
Show Gist options
  • Save narita1980/2935175 to your computer and use it in GitHub Desktop.
Save narita1980/2935175 to your computer and use it in GitHub Desktop.
InputStreamをStringに変換するプログラム
/*
* 参考サイト
* http://d.hatena.ne.jp/gungnir_odin/20091129/1259333223
*/
public class Utils {
public static String inputStreemToString(InputStream in) throws IOException{
BufferedReader reader =
new BufferedReader(new InputStreamReader(in, "UTF-8"/* 文字コード指定 */));
StringBuffer buf = new StringBuffer();
String str;
while ((str = reader.readLine()) != null) {
buf.append(str);
buf.append("\n");
}
return buf.toString();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment