Here you can find the source of copyLarge(InputStream input, OutputStream output)
public static long copyLarge(InputStream input, OutputStream output) throws IOException
//package com.java2s; /******************************************************************************* * Copyright (c) 2012 Google, Inc./*from w w w .ja v a2 s.c om*/ * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Google, Inc. - initial API and implementation *******************************************************************************/ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; public class Main { private static final int DEFAULT_BUFFER_SIZE = 1024 * 4; public static long copyLarge(InputStream input, OutputStream output) throws IOException { byte[] buffer = new byte[DEFAULT_BUFFER_SIZE]; long count = 0; int n = 0; while (-1 != (n = input.read(buffer))) { output.write(buffer, 0, n); count += n; } return count; } }