Here you can find the source of readLine()
public static String readLine()
//package com.java2s; /*/*w w w . j a v a 2 s . c o m*/ * Copyright 2002 Felix Pahl. All rights reserved. * Use is subject to license terms. */ import java.io.IOException; import java.io.ByteArrayOutputStream; public class Main { public static String readLine() { ByteArrayOutputStream baos = new ByteArrayOutputStream(); int c; try { while ((c = System.in.read()) != '\n') if (c != '\r') baos.write(c); } catch (IOException ioe) { ioe.printStackTrace(); throw new Error("couldn't read from standard input"); } return baos.toString(); } }