Here you can find the source of getFileContent(InputStream stream)
public static String getFileContent(InputStream stream) throws IOException
//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 } }