Android examples for java.lang:StringBuilder
Read InputStream To String using StringBuilder
import android.util.Log; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; public class Main{ public static String inputStreamToString(final InputStream stream) throws IOException { Log.v(StringUtils.class.getSimpleName(), "Inside inputStreamToString"); BufferedReader br = new BufferedReader( new InputStreamReader(stream)); StringBuilder sb = new StringBuilder(); String line = null;//from w ww .j a v a 2 s .c om while ((line = br.readLine()) != null) { sb.append(line + "\n"); } br.close(); Log.v(StringUtils.class.getSimpleName(), "before existing inputStreamToString"); return sb.toString(); } }