Here you can find the source of loadFully(final InputStream aStream)
public static final byte[] loadFully(final InputStream aStream) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; public class Main { public static final byte[] loadFully(final InputStream aStream) throws IOException { final ByteArrayOutputStream bytes = new ByteArrayOutputStream(); copy(aStream, bytes);/*from www .ja va2 s. c o m*/ return bytes.toByteArray(); } public static final void copy(final InputStream aInput, final OutputStream aOutput) throws IOException { final byte[] buffer = new byte[4096]; while (true) { final int newBytes = aInput.read(buffer); if (newBytes == -1) break; aOutput.write(buffer, 0, newBytes); } } }