Java BufferedReader Read All readAll(final Reader reader)

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

Description

read All

License

Open Source License

Declaration

public static String readAll(final Reader reader) throws IOException 

Method Source Code


//package com.java2s;
// The MIT License

import java.io.BufferedReader;

import java.io.IOException;

import java.io.Reader;

public class Main {
    public static String readAll(final Reader reader) throws IOException {
        final StringBuffer buffer = new StringBuffer();

        final BufferedReader in = new BufferedReader(reader);
        int ch;/*w  ww.j  a  va2 s.  co  m*/
        while ((ch = in.read()) > -1) {
            buffer.append((char) ch);
        }
        in.close();
        return buffer.toString();
    }
}

Related

  1. readAll(File f)
  2. readAll(File file)
  3. readAll(File file)
  4. readAll(File file)
  5. readAll(File input)
  6. readAll(InputStream in)
  7. readAll(InputStream in)
  8. readAll(InputStream in, String encoding)
  9. readAll(InputStream input)