Here you can find the source of readAll(InputStream inputStream)
public static byte[] readAll(InputStream inputStream) throws IOException
//package com.java2s; //License from project: Apache License import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; public class Main { public static byte[] readAll(InputStream inputStream) throws IOException { ByteArrayOutputStream bout = new ByteArrayOutputStream(); byte[] buffer = new byte[1024]; while (true) { int len = inputStream.read(buffer); if (len < 0) { break; }//w ww .j a va 2 s. c o m bout.write(buffer, 0, len); } byte[] result = bout.toByteArray(); bout.close(); return result; } }