Here you can find the source of readLine(final InputStream in)
public static String readLine(final InputStream in) throws IOException
//package com.java2s; //License from project: LGPL import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; public class Main { private static final int CR = 13; private static final int LF = 10; private static final int EOF = -1; public static String readLine(final InputStream in) throws IOException { final ByteArrayOutputStream out = new ByteArrayOutputStream(); while (true) { final int b = in.read(); switch (b) { case EOF: if (out.size() != 0) { return out.toString(); }/*w w w . j a v a2 s. c om*/ return null; case CR: break; case LF: return out.toString(); default: out.write(b); break; } } } }