Java tutorial
//package com.java2s; import java.io.IOException; import java.io.Reader; import java.io.Writer; public class Main { private static final int DEFAULT_BUFFER_SIZE = 1024 * 4; public static long copyLarge(Reader input, Writer output) throws IOException { char[] buffer = new char[DEFAULT_BUFFER_SIZE]; long count = 0; int n = 0; while (-1 != (n = input.read(buffer))) { output.write(buffer, 0, n); count += n; } return count; } }