Java InputStream Read getFileContent(InputStream stream)

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

Description

get File Content

License

Open Source License

Declaration

public static String getFileContent(InputStream stream) throws IOException 

Method Source Code


//package com.java2s;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

public class Main {
    public static String getFileContent(InputStream stream) throws IOException {
        InputStreamReader reader = new InputStreamReader(stream);

        char[] arr = new char[8 * 1024]; // 8K at a time
        StringBuilder buf = new StringBuilder();
        int numChars;
        while ((numChars = reader.read(arr, 0, arr.length)) > 0) {
            buf.append(arr, 0, numChars);
        }/*from w  w w  .  j ava 2  s  .  co  m*/
        return buf.toString().intern(); // if file already read return java cached string
    }
}

Related

  1. getFileContent(InputStream in)
  2. getFileContent(InputStream inputStream)
  3. getFileContent(InputStream is)
  4. getInputStream(Class clazz)
  5. getInputStream(Class ownerClass, String subName, String extension)
  6. getInputstream(File compressedFile)
  7. getInputStream(JarFile file, ZipEntry entry)