Java ByteArrayOutputStream Read Line readLine()

Here you can find the source of readLine()

Description

read Line

License

Open Source License

Declaration

public static String readLine() 

Method Source Code

//package com.java2s;
/*/*w  w  w . j a v  a  2 s  .  c  o m*/
 * Copyright 2002 Felix Pahl. All rights reserved.
 * Use is subject to license terms.
 */

import java.io.IOException;

import java.io.ByteArrayOutputStream;

public class Main {
    public static String readLine() {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        int c;
        try {
            while ((c = System.in.read()) != '\n')
                if (c != '\r')
                    baos.write(c);
        } catch (IOException ioe) {
            ioe.printStackTrace();
            throw new Error("couldn't read from standard input");
        }
        return baos.toString();
    }
}

Related

  1. readLine(final InputStream in)
  2. readLine(InputStream in)
  3. readLine(InputStream in)
  4. readLine(InputStream in)