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

public 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 {
    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;
    }
}

Related

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