Here you can find the source of readFile(InputStream inputStream)
public static void readFile(InputStream inputStream) throws IOException
//package com.java2s; //License from project: Apache License import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; public class Main { public static void readFile(InputStream inputStream) throws IOException { InputStreamReader in = new InputStreamReader(inputStream); BufferedReader reader = new BufferedReader(in); String line;/*from w ww . j a v a2 s . c om*/ while ((line = reader.readLine()) != null) { System.out.println(line); } reader.close(); } public static String readFile(File file, String encoding) { StringBuffer buffer = new StringBuffer(); try { FileInputStream inputStream = new FileInputStream(file); InputStreamReader inputStreamReader = new InputStreamReader(inputStream, encoding); BufferedReader reader = new BufferedReader(inputStreamReader); String tempString = null; while ((tempString = reader.readLine()) != null) { buffer.append(tempString + "\n"); } reader.close(); } catch (Exception e) { } return buffer.toString(); } public static String readFile(String filename, String encoding) { return readFile(new File(filename), encoding); } public static String readFile(File file) { StringBuffer buffer = new StringBuffer(); try { FileInputStream inputStream = new FileInputStream(file); InputStreamReader inputStreamReader = new InputStreamReader(inputStream); BufferedReader reader = new BufferedReader(inputStreamReader); String tempString = null; while ((tempString = reader.readLine()) != null) { buffer.append(tempString + "\n"); } reader.close(); } catch (Exception e) { } return buffer.toString(); } public static String readFile(String filename) { return readFile(new File(filename)); } }