Java Reader Copy copyLarge(Reader input, Writer output)

Here you can find the source of copyLarge(Reader input, Writer output)

Description

copy Large

License

Open Source License

Declaration

public static long copyLarge(Reader input, Writer output) throws IOException 

Method Source Code

//package com.java2s;
/**//ww w.jav a2 s  .c  om
 * Copyright (c) 2011 Samson Wu
 * Permission is hereby granted, free of charge, to any person obtaining
 * a copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 * 
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 * 
 */

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;
    }
}

Related

  1. copyLarge(Reader input, Writer output)
  2. copyLarge(Reader input, Writer output)
  3. copyLarge(Reader input, Writer output)
  4. copyLarge(Reader input, Writer output)
  5. copyLarge(Reader input, Writer output)
  6. copyLarge(Reader input, Writer output)
  7. copyLarge(Reader input, Writer output)
  8. copyLarge(Reader input, Writer output)
  9. copyLarge(Reader input, Writer output)