Here you can find the source of dumpInputStreamIntoString(InputStream f, String encoding)
public static String dumpInputStreamIntoString(InputStream f, String encoding) throws Exception
//package com.java2s; //License from project: Apache License import java.io.BufferedInputStream; import java.io.ByteArrayOutputStream; import java.io.InputStream; public class Main { public static String dumpInputStreamIntoString(InputStream f, String encoding) throws Exception { ByteArrayOutputStream byteStream = null; BufferedInputStream fileStream = null; byteStream = new ByteArrayOutputStream(); fileStream = new BufferedInputStream((f)); int data = -1; while ((data = fileStream.read()) != -1) { byteStream.write(data);/* w w w. ja va 2 s. c o m*/ } byte[] raw = byteStream.toByteArray(); return new String(raw, encoding); } }