Java ByteArrayOutputStream Read Line readLine(InputStream inputStream)

Here you can find the source of readLine(InputStream inputStream)

Description

read Line

License

Open Source License

Declaration

private static String readLine(InputStream inputStream) throws IOException 

Method Source Code


//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;
    }
}

Related

  1. readLine(InputStream in, char character)
  2. readLine(InputStream input)
  3. readLine(InputStream inputStream)
  4. readLine(InputStream inputStream)
  5. readLine(InputStream inputstream)
  6. readLine(InputStream is)
  7. readLine(Reader ir)