Java BufferedReader Read All readAll(InputStream stream)

Here you can find the source of readAll(InputStream stream)

Description

read All

License

Open Source License

Declaration

public static String readAll(InputStream stream) throws Exception 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

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

public class Main {
    public static String readAll(InputStream stream) throws Exception {
        BufferedReader reader = null;
        try {/*from w  w  w.j  a v a 2 s .  c om*/
            reader = new BufferedReader(new InputStreamReader(stream));
            StringBuilder b = new StringBuilder();
            String line = null;
            while ((line = reader.readLine()) != null) {
                b.append(line);
            }
            return b.toString();
        } finally {
            if (reader != null)
                reader.close();
        }
    }
}

Related

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