Java tutorial
//package com.java2s; import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; public class Main { public static String convertStreamToString(InputStream is) throws Exception { BufferedReader reader = new BufferedReader(new InputStreamReader(is)); StringBuilder sb = new StringBuilder(); String line = null; String NL = System.getProperty("line.separator"); while ((line = reader.readLine()) != null) { sb.append(line + NL); } sb.replace(sb.length() - 1, sb.length(), ""); is.close(); return sb.toString(); } }