Here you can find the source of readLine(InputStream in)
private static String readLine(InputStream in) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; public class Main { private static String readLine(InputStream in) throws IOException { ByteArrayOutputStream bos = new ByteArrayOutputStream(); boolean eol = false; byte[] b = new byte[1]; while (in.read(b, 0, 1) != -1) { if (b[0] == 13) { eol = true;//from ww w . j a va 2s . c o m } else { if ((eol) && (b[0] == 10)) { break; } eol = false; } bos.write(b, 0, 1); } if (bos.size() == 0) { return null; } return bos.toString().trim(); } }