Here you can find the source of readInputStreamToString(InputStream input, String enCoding)
public static String readInputStreamToString(InputStream input, String enCoding)
//License from project: Apache License import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; import java.util.ArrayList; import java.util.List; public class Main{ private static LogUtil log = LogUtil.getLogger(FileUtil.class); /*from www. j a v a 2 s. c o m*/ public static String readInputStreamToString(InputStream input, String enCoding) { BufferedReader reader; StringBuilder sb = new StringBuilder(); String line = null; try { reader = new BufferedReader(new InputStreamReader(input, enCoding)); while ((line = reader.readLine()) != null) { sb.append(line + "\r\n"); } } catch (IOException e) { log.error(e.getMessage()); } finally { try { input.close(); } catch (IOException e) { log.error(e.getMessage()); } } return sb.toString(); } }