Java tutorial
//package com.java2s; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; public class Main { public static CharSequence toString(InputStream is) { try { BufferedReader r = new BufferedReader(new InputStreamReader(is)); StringBuilder total = new StringBuilder(is.available()); String line; while ((line = r.readLine()) != null) { total.append(line); } return total; } catch (IOException e) { e.printStackTrace(); return null; } } }