Here you can find the source of readAllBuffer(InputStream stream, byte[] buffer)
public static int readAllBuffer(InputStream stream, byte[] buffer) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.IOException; import java.io.InputStream; public class Main { public static int readAllBuffer(InputStream stream, byte[] buffer) throws IOException { return readAllBuffer(stream, buffer, 0, buffer.length); }//from w w w . j a v a 2s. c o m public static int readAllBuffer(InputStream stream, byte[] buffer, int off, int len) throws IOException { int total = 0; do { int l = len - total; int nb = stream.read(buffer, off, l); if (nb <= 0) return total; off += nb; total += nb; } while (total < len); return total; } }