Here you can find the source of ReadTextFile(InputStream is)
public static String ReadTextFile(InputStream is) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.BufferedReader; import java.io.DataInputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; public class Main { public static String ReadTextFile(InputStream is) throws IOException { DataInputStream dis = new DataInputStream(is); BufferedReader br = new BufferedReader(new InputStreamReader(dis), 16 * 1024); StringBuilder str = new StringBuilder(); String line;/*w w w . j a v a 2s . c om*/ while ((line = br.readLine()) != null) { str.append(line); str.append("\n"); } dis.close(); return str.toString(); } }