Here you can find the source of copyLarge(InputStream input, OutputStream output)
Parameter | Description |
---|---|
input | the <code>InputStream</code> to read from |
output | the <code>OutputStream</code> to write to |
Parameter | Description |
---|---|
NullPointerException | if the input or output is null |
IOException | if an I/O error occurs |
public static long copyLarge(InputStream input, OutputStream output) throws IOException
//package com.java2s; //License from project: LGPL import java.io.*; public class Main { /**//from www. ja v a2s.c o m * default buffer size */ private static final int DEFAULT_BUFFER_SIZE = 1024 * 4; /** * End of File */ private static final int EOF = -1; /** * @param input the <code>InputStream</code> to read from * @param output the <code>OutputStream</code> to write to * @return the number of bytes copied * @throws NullPointerException if the input or output is null * @throws IOException if an I/O error occurs */ public static long copyLarge(InputStream input, OutputStream output) throws IOException { return copyLarge(input, output, new byte[DEFAULT_BUFFER_SIZE]); } /** * @param input the <code>InputStream</code> to read from * @param output the <code>OutputStream</code> to write to * @return the number of bytes copied * @throws NullPointerException if the input or output is null * @throws IOException if an I/O error occurs */ public static long copyLarge(InputStream input, OutputStream output, byte[] buffer) throws IOException { long count = 0; int n = 0; while (EOF != (n = input.read(buffer))) { output.write(buffer, 0, n); count += n; } return count; } }