Java BufferedReader Read All readAll(InputStream in)

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

Description

read All

License

Apache License

Declaration

static String readAll(InputStream in) throws Exception 

Method Source Code


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

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

public class Main {
    static String readAll(InputStream in) throws Exception {
        return readAll(in, new StringBuilder());
    }//from  w w  w. j a v a2s.  c  om

    public static String readAll(InputStream in, StringBuilder sb) throws Exception {
        final BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        String line;
        while ((line = reader.readLine()) != null) {
            sb.append(line);
            sb.append('\n');
        }
        return sb.toString();
    }
}

Related

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