Here you can find the source of getFileContentAsString(InputStream inputStream)
public static String getFileContentAsString(InputStream inputStream) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.IOException; import java.io.InputStream; public class Main { /** Reads the content of a given file as a String and returns it. * @return the content of the given file as a String */ public static String getFileContentAsString(InputStream inputStream) throws IOException { String data = ""; byte[] buffer = new byte[1024]; int numRead = -1; while (true) { numRead = inputStream.read(buffer); if (numRead == 1024) { data += new String(buffer); } else { if (numRead != -1) data += new String(buffer, 0, numRead); break; }/*from w w w .ja v a 2s.c o m*/ } return data; } }