Here you can find the source of readFully(InputStream inputStream)
public static byte[] readFully(InputStream inputStream) 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[] readFully(InputStream inputStream) throws IOException { ByteArrayOutputStream os = new ByteArrayOutputStream(); int byteCount; byte[] buffer = new byte[1024]; while ((byteCount = inputStream.read(buffer)) != -1) { os.write(buffer, 0, byteCount); }/*from ww w . j av a2 s .c o m*/ return os.toByteArray(); } }