Java InputStreamReader Read All readAll(InputStreamReader reader)

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

Description

read All

License

LGPL

Declaration

public static String readAll(InputStreamReader reader) throws IOException 

Method Source Code


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

import java.io.IOException;

import java.io.InputStreamReader;

public class Main {

    public static String readAll(InputStreamReader reader) throws IOException {
        char[] buffer = new char[1024];
        StringBuilder contents = new StringBuilder();
        int len = 0;
        while ((len = reader.read(buffer)) != -1) {
            contents.append(buffer, 0, len);
        }/* ww w . j a  va  2 s  .  c o m*/
        reader.close();
        return contents.toString();
    }
}

Related

  1. readAll(File file)
  2. readAll(InputStream input)
  3. readAll(Reader source)