Here you can find the source of copyLarge(final InputStream input, final OutputStream output)
private static long copyLarge(final InputStream input, final OutputStream output) throws IOException
//package com.java2s; //License from project: Apache License import java.io.*; public class Main { private static final int EOF = -1; private static final int DEFAULT_BUFFER_SIZE = 1024 * 4; private static long copyLarge(final InputStream input, final OutputStream output, final byte[] buffer) throws IOException { long count = 0; int n;//from ww w .ja v a2 s .com while (EOF != (n = input.read(buffer))) { output.write(buffer, 0, n); count += n; } return count; } private static long copyLarge(final InputStream input, final OutputStream output) throws IOException { return copy(input, output, DEFAULT_BUFFER_SIZE); } private static long copy(final InputStream input, final OutputStream output, final int bufferSize) throws IOException { return copyLarge(input, output, new byte[bufferSize]); } public static int copy(final InputStream input, final OutputStream output) throws IOException { final long count = copyLarge(input, output); if (count > Integer.MAX_VALUE) { return -1; } return (int) count; } }