Here you can find the source of readLine(InputStream inputStream)
private 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 { private static String readLine(InputStream inputStream) throws IOException { ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); int c;//from w w w. jav a2s . co m for (c = inputStream.read(); c != '\n' && c != -1; c = inputStream.read()) { byteArrayOutputStream.write(c); } if (c == -1 && byteArrayOutputStream.size() == 0) { return null; } String line = byteArrayOutputStream.toString("UTF-8"); return line; } }