Here you can find the source of toString(InputStream is)
public static String toString(InputStream is) throws IOException
//package com.java2s; import java.io.*; public class Main { public static String toString(InputStream is) throws IOException { if (null == is) { return null; }/*w w w .j a v a 2s . co m*/ return toStringBuffer(is).toString(); } public static StringBuilder toStringBuffer(InputStream is) throws IOException { if (null == is) { return null; } BufferedReader in = new BufferedReader(new InputStreamReader(is)); StringBuilder buffer = new StringBuilder(); String line = null; while ((line = in.readLine()) != null) { buffer.append(line).append("\n"); } is.close(); return buffer; } }