Here you can find the source of copyLarge(InputStream input, OutputStream output, byte[] buffer)
private static long copyLarge(InputStream input, OutputStream output, byte[] buffer) throws IOException
//package com.java2s; //License from project: Apache License import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; public class Main { private static final int EOF = -1; private static long copyLarge(InputStream input, OutputStream output, byte[] buffer) throws IOException { long count = 0; int n;//from w w w . ja v a 2 s .c o m while (EOF != (n = input.read(buffer))) { output.write(buffer, 0, n); count += n; } return count; } public static int read(InputStream input, byte[] buffer) throws IOException { int remaining = buffer.length; while (remaining > 0) { int location = buffer.length - remaining; int count = input.read(buffer, 0 + location, remaining); if (EOF == count) { // EOF break; } remaining -= count; } return buffer.length - remaining; } }