Java BufferedReader Read All readAllText(final InputStream inputStream)

Here you can find the source of readAllText(final InputStream inputStream)

Description

read All Text

License

Open Source License

Declaration

public static String readAllText(final 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 {
    public static String readAllText(final InputStream inputStream) throws IOException {
        try (final BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream))) {

            final StringBuffer buff = new StringBuffer();

            String line = null;/*from ww  w .  j a v  a2 s .co  m*/

            while ((line = reader.readLine()) != null) {
                buff.append(line + System.lineSeparator());
            }

            return buff.toString();
        } catch (NullPointerException e) {
            throw e;
        }
    }
}

Related

  1. readAllLines(String filepath)
  2. readAllStreamFromClasspathBaseResource(Class resourceBase, String dataLocation)
  3. readAllStreamsFromClasspathBaseResource(Class resourceBase, String[] dataLocations)
  4. readAllText(File file)
  5. readAllText(File file)
  6. readAllText(InputStream stream)
  7. readAllText(String filePath)
  8. readAllText(String path)
  9. readAllTextFromSystemResource(String path)