Java InputStreamReader Create ReadTextFile(InputStream is)

Here you can find the source of ReadTextFile(InputStream is)

Description

Read Text File

License

Open Source License

Declaration

public static String ReadTextFile(InputStream is) throws IOException 

Method Source Code


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

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

public class Main {
    public static String ReadTextFile(InputStream is) throws IOException {
        DataInputStream dis = new DataInputStream(is);

        BufferedReader br = new BufferedReader(new InputStreamReader(dis), 16 * 1024);

        StringBuilder str = new StringBuilder();

        String line;/*w w w  .  j a  v  a  2s .  c om*/

        while ((line = br.readLine()) != null) {
            str.append(line);
            str.append("\n");
        }

        dis.close();

        return str.toString();
    }
}

Related

  1. readTextFile(File fromFile)
  2. readTextFile(File inputFile)
  3. readTextFile(File path)
  4. readTextFile(final File f)
  5. readTextFile(final File file)
  6. readTextFile(java.io.File file)
  7. readTextFile(Reader reader)
  8. readTextFile(String fileName)
  9. readTextFile(String filename, int maxNumLines, boolean startAtBeginning)