Here you can find the source of readLine(InputStream in)
Parameter | Description |
---|---|
in | a parameter |
Parameter | Description |
---|---|
IOException | an exception |
public static byte[] readLine(InputStream in) throws IOException
//package com.java2s; /**//from w ww . ja va 2 s .co m * License * * Licensed under the GNU GPL v3 * http://www.gnu.org/licenses/gpl.html * */ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; public class Main { /** * \r\n * * @param in * @return * @throws IOException */ public static byte[] readLine(InputStream in) throws IOException { ByteArrayOutputStream bts = new ByteArrayOutputStream(); int last = 0; while (true) { int b = in.read(); if (b == -1) break; bts.write(b); if (last == '\r' && b == '\n') { break; } last = b; } return bts.toByteArray(); } }