Here you can find the source of streamToByteArray(InputStream paramInputStream)
public static byte[] streamToByteArray(InputStream paramInputStream) throws IOException
//package com.java2s; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; public class Main { public static byte[] streamToByteArray(InputStream paramInputStream) throws IOException { byte[] arrayOfByte = new byte[4096]; ByteArrayOutputStream localByteArrayOutputStream = new ByteArrayOutputStream(); while (true) { int i = paramInputStream.read(arrayOfByte); if (i == -1) break; localByteArrayOutputStream.write(arrayOfByte, 0, i); }/*ww w .j av a 2 s . com*/ return localByteArrayOutputStream.toByteArray(); } }