Here you can find the source of inputStreamToStringBuffer(InputStream stream)
public static StringBuffer inputStreamToStringBuffer(InputStream stream) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; public class Main { public static StringBuffer inputStreamToStringBuffer(InputStream stream) throws IOException { InputStreamReader reader = new InputStreamReader(stream); StringBuffer str = new StringBuffer(); char[] buff = new char[8192]; int len = 0; while ((len = reader.read(buff)) != -1) { str.append(buff, 0, len);/* w w w.j a v a 2 s .co m*/ } reader.close(); return str; } }