Here you can find the source of readLine(InputStream inputStream)
public static String readLine(InputStream inputStream) 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 { public static String readLine(InputStream inputStream) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); int ch;/*from w w w . j a v a2 s .co m*/ while (((ch = inputStream.read()) != '\n')) { if (ch == -1) break; baos.write(ch); } String result = baos.toString(); if (result != null && result.trim().equals("")) result = "0"; return result; } }