Java tutorial
//package com.java2s; import java.io.IOException; import java.io.InputStream; public class Main { public static String readLine(InputStream in) throws IOException { StringBuilder result = new StringBuilder(); for (int c; (c = in.read()) != -1 && c != '\n';) { if (c != '\r') { result.append((char) c); } } return result.toString(); } }