Created
June 15, 2012 07:18
-
-
Save narita1980/2935175 to your computer and use it in GitHub Desktop.
InputStreamをStringに変換するプログラム
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 参考サイト | |
* 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