Java BufferedReader Read All readAllFromInputStream(InputStream inputStream)

Here you can find the source of readAllFromInputStream(InputStream inputStream)

Description

Read all the content from an InputStream instance.

License

Open Source License

Parameter

Parameter Description
inputStream the instance from which you want to read.

Return

Read all the content from an inputStream instance.

Declaration

public static String readAllFromInputStream(InputStream inputStream) throws IOException 

Method Source Code


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

import java.io.BufferedReader;

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

public class Main {
    /**/*from w w w  .j av  a  2 s  .c om*/
     * Read all the content from an InputStream instance.
     * @param inputStream the instance from which you want to read.
     * @return Read all the content from an inputStream instance.
     */
    public static String readAllFromInputStream(InputStream inputStream) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
        String result = "", line = "";
        while ((line = reader.readLine()) != null) {
            result += line;
        }
        return result;
    }
}

Related

  1. readAll(String path)
  2. ReadAll_Variant2(Reader rd, Writer wr)
  3. readAllCourseNum()
  4. readAllCoursePro()
  5. readAllCourseTime()
  6. readAllFromInputStreamAsList(InputStream inputStream)
  7. ReadAllFromStream(InputStream source)
  8. readAllLines(File file)
  9. readAllLines(File file)