Here you can find the source of readLine(InputStream is)
public static String readLine(InputStream is) throws IOException
//package com.java2s; /**/*from w w w. ja v a 2 s . c o m*/ * Copyright (C) 2011 Inqwell Ltd * * You may distribute under the terms of the Artistic License, as specified in * the README file. */ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; public class Main { public static String readLine(InputStream is) throws IOException { int byteRead; int offset = 0; int priorByte = -1; String ret = null; ByteArrayOutputStream bos = new ByteArrayOutputStream(80); while (true) { byteRead = is.read(); if (byteRead < 0) { bos.reset(); bos.close(); throw new IOException("readline: Premature EOF"); } //if (byteRead == '\n' && priorByte == '\r') if (byteRead == '\n') { ret = bos.toString(); bos.reset(); bos.close(); return ret; } if (byteRead != '\r') bos.write(byteRead); priorByte = byteRead; } } }