Here you can find the source of readFileFully(InputStream stream)
public static String readFileFully(InputStream stream) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.IOException; import java.io.InputStream; import java.util.Scanner; public class Main { public static String readFileFully(InputStream stream) throws IOException { StringBuilder stringBuilder = new StringBuilder(); try (Scanner scanner = new Scanner(stream)) { while (scanner.hasNext()) { stringBuilder.append(scanner.next()); }//from w w w .java 2 s . com } return stringBuilder.toString(); } public static String toString(java.io.InputStream is) { try (Scanner scanner = new java.util.Scanner(is).useDelimiter("\\A")) { return scanner.hasNext() ? scanner.next() : ""; } } }