Here you can find the source of readInputStream(InputStream inStream)
public static byte[] readInputStream(InputStream inStream) throws Exception
//package com.java2s; import java.io.ByteArrayOutputStream; import java.io.InputStream; public class Main { public static byte[] readInputStream(InputStream inStream) throws Exception { ByteArrayOutputStream outSteam = new ByteArrayOutputStream(); byte[] buffer = new byte[4096]; int len = 0; while ((len = inStream.read(buffer)) != -1) { outSteam.write(buffer, 0, len); }//from w ww . j a va 2s .co m outSteam.close(); inStream.close(); return outSteam.toByteArray(); } }