Java tutorial
//package com.java2s; // license that can be found in the LICENSE file. import java.io.IOException; import java.io.InputStream; public class Main { /** * Reads until a '\n', and returns the line as a string, with '\n' * included. * * Returns the empty string if EOF is reached. */ public static String readLine(InputStream input) throws IOException { StringBuilder builder = new StringBuilder(); while (true) { int v = input.read(); if (v == -1) { break; } char ch = (char) v; builder.append(ch); if (ch == '\n') { break; } } return builder.toString(); } }