Here you can find the source of readLine(InputStream in, OutputStream out)
public static int readLine(InputStream in, OutputStream out) throws IOException
//package com.java2s; import java.io.*; public class Main { /**/*from ww w . j a v a 2 s . c om*/ * Implementation only supports unix line-end format and is suitable for * processing HTTP and other network protocol communications. Reads and writes * a line of data. Returns the number of bytes read/written. */ public static int readLine(InputStream in, OutputStream out) throws IOException { int count = 0; for (;;) { int b = in.read(); if (b == -1) { break; } count++; out.write(b); if (b == '\n') { break; } } return count; } }