Java tutorial
//package com.java2s; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static String readInputStream(InputStreamReader in) { StringBuilder sb = new StringBuilder(); try { BufferedReader reader = new BufferedReader(in); char[] temp = new char[1024]; int length; while ((length = reader.read(temp)) != -1) { if (Thread.currentThread().isInterrupted()) break; sb.append(temp, 0, length); } reader.close(); } catch (Exception e) { e.printStackTrace(); } finally { try { in.close(); } catch (IOException e) { } } return (sb.toString()); } }