Here you can find the source of readFile(InputStream input)
public static String readFile(InputStream input)
//package com.java2s; import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStream; import java.io.InputStream; public class Main { public static String readFile(File in) { try {/*from w w w . j av a 2 s.c om*/ return readFile(new FileInputStream(in)); } catch (Exception e) { e.printStackTrace(); return null; } } public static String readFile(InputStream input) { BufferedInputStream reader = null; String rt = null; try { byte[] buffer = new byte[input.available()]; reader = new BufferedInputStream(input); reader.read(buffer); reader.close(); input.close(); rt = new String(buffer); } catch (Exception e) { e.printStackTrace(); return rt; } finally { try { if (input != null) input.close(); if (reader != null) reader.close(); } catch (Exception e) { } } return rt; } }