Java Utililty Methods ByteArrayOutputStream Read Line

List of utility methods to do ByteArrayOutputStream Read Line

Description

The list of methods to do ByteArrayOutputStream Read Line are organized into topic(s).

Method

StringreadLine()
read Line
ByteArrayOutputStream baos = new ByteArrayOutputStream();
int c;
try {
    while ((c = System.in.read()) != '\n')
        if (c != '\r')
            baos.write(c);
} catch (IOException ioe) {
    ioe.printStackTrace();
...
StringreadLine(final InputStream in)
read Line
final ByteArrayOutputStream out = new ByteArrayOutputStream();
while (true) {
    final int b = in.read();
    switch (b) {
    case EOF:
        if (out.size() != 0) {
            return out.toString();
        return null;
    case CR:
        break;
    case LF:
        return out.toString();
    default:
        out.write(b);
        break;
StringreadLine(InputStream in)
read one line.
ByteArrayOutputStream sb = new ByteArrayOutputStream();
while (true) {
    int c = in.read();
    if (c < 0) {
        if (sb.size() == 0) {
            return null; 
        break;
...
StringreadLine(InputStream in)
A simple method to read a complete line from an InputStream.
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
int c = 0;
while ((c = in.read()) != -1 && c != LF) {
    if (c != CR) 
        bytes.write(c);
return new String(bytes.toByteArray());
byte[]readLine(InputStream in)
\r\n
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') {
...
StringreadLine(InputStream in)
read Line
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;
    } else {
        if ((eol) && (b[0] == 10)) {
...
StringreadLine(InputStream in)
read Line
ByteArrayOutputStream baos = new ByteArrayOutputStream();
while (true) {
    if (new String(baos.toByteArray()).endsWith("\r\n")) {
        break;
    baos.write(in.read());
return new String(baos.toByteArray()).trim();
...
StringreadLine(InputStream in)
Reads from the input stream until a linefeed is encountered.
ByteArrayOutputStream baos = new ByteArrayOutputStream();
int c = in.read();
if (c == -1 || c == '\n')
    return "";
int c2 = in.read();
while (c2 != -1 && (char) c2 != '\n') {
    baos.write(c);
    c = c2;
...
StringreadLine(InputStream in)

Read a full line from an input stream, returning it in a string.

ByteArrayOutputStream out = new ByteArrayOutputStream();
int b = in.read();
while ((b != '\r') && (b != '\n') && (b != -1)) {
    out.write(b);
    b = in.read();
if (b == '\r')
    in.read(); 
...
StringreadLine(InputStream in, char character)
read Line
ByteArrayOutputStream buf = new ByteArrayOutputStream();
while (true) {
    int value = in.read();
    if (value == -1) {
        throw new EOFException();
    if (value == character) {
        break;
...