Java tutorial
//package com.java2s; //License from project: Apache License import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; public class Main { public static String readLine(InputStream in) { final BufferedReader reader = new BufferedReader(new InputStreamReader(in)); final StringBuilder out = new StringBuilder(); final String newLine = System.getProperty("line.separator"); String line; try { while ((line = reader.readLine()) != null) { out.append(line); out.append(newLine); } } catch (final IOException e) { throw new RuntimeException(e); } return out.toString(); } }