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;
    }
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 ; }
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.