Java tutorial
//package com.java2s; //License from project: Apache License import java.io.*; public class Main { public static String readContents(InputStream input) { StringBuilder sb = new StringBuilder(); int ch; while (true) { try { ch = input.read(); if (ch != -1) sb.append((char) ch); else break; } catch (IOException e) { break; } } return sb.toString(); } }