Here you can find the source of toStringBuffer(InputStream is)
public static StringBuilder toStringBuffer(InputStream is) throws IOException
//package com.java2s; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; public class Main { 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;//from w ww .ja va 2 s .c o m while ((line = in.readLine()) != null) { buffer.append(line).append("\n"); } is.close(); return buffer; } }