Java BufferedReader Read All readAll(Reader reader)

Here you can find the source of readAll(Reader reader)

Description

read All

License

Apache License

Declaration

public static String readAll(Reader reader) throws IOException 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;

public class Main {
    public static String readAll(InputStream stream) throws IOException {
        Reader reader = new BufferedReader(new InputStreamReader(stream));

        return readAll(reader);
    }/*from www .j a  v  a2  s . co  m*/

    public static String readAll(Reader reader) throws IOException {
        StringBuilder buf = new StringBuilder();
        int in;
        while ((in = reader.read()) != -1) {
            char ch = (char) in;
            buf.append(ch);
        }
        return buf.toString();
    }
}

Related

  1. readAll(InputStream in)
  2. readAll(InputStream in)
  3. readAll(InputStream in, String encoding)
  4. readAll(InputStream input)
  5. readAll(InputStream stream)
  6. readAll(Reader reader)
  7. readAll(Reader reader)
  8. readAll(Reader reader)
  9. readAll(String fileName)