Here you can find the source of readLine(BufferedReader reader)
public static String readLine(BufferedReader reader) throws IOException
//package com.java2s; //License from project: Apache License import java.io.BufferedReader; import java.io.IOException; public class Main { public static String readLine(BufferedReader reader) throws IOException { int ch = -1; StringBuffer line = new StringBuffer(); ch = reader.read();/*from ww w .ja v a2s.c o m*/ while ((ch != -1) && (ch != 13) && (ch != 10)) { line.append((char) ch); ch = reader.read(); } if ((ch == -1) && (line.length() == 0)) { return null; } switch ((char) ch) { case '\r': reader.mark(2); switch (ch = reader.read()) { case 13: if ((char) (ch = reader.read()) == '\n') break; reader.reset(); break; case 10: break; case -1: break; default: reader.reset(); } break; case '\n': } return line.toString(); } }