Here you can find the source of readAll(InputStream aInputStream)
public static byte[] readAll(InputStream aInputStream) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; public class Main { public static byte[] readAll(InputStream aInputStream) throws IOException { try (InputStream in = aInputStream) { byte[] buffer = new byte[4096]; ByteArrayOutputStream baos = new ByteArrayOutputStream(); for (;;) { int len = in.read(buffer); if (len <= 0) { break; }/*from w w w. j av a2 s .co m*/ baos.write(buffer, 0, len); } return baos.toByteArray(); } } }