Java InputStream Copy copyLarge(InputStream input, OutputStream output, byte[] buffer)

Here you can find the source of copyLarge(InputStream input, OutputStream output, byte[] buffer)

Description

copy Large

License

Apache License

Declaration

private static long copyLarge(InputStream input, OutputStream output, byte[] buffer) throws IOException 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

public class Main {
    private static final int EOF = -1;

    private static long copyLarge(InputStream input, OutputStream output, byte[] buffer) throws IOException {
        long count = 0;
        int n;//from  w  w  w  .  ja  v  a  2 s .c  o  m
        while (EOF != (n = input.read(buffer))) {
            output.write(buffer, 0, n);
            count += n;
        }
        return count;
    }

    public static int read(InputStream input, byte[] buffer) throws IOException {
        int remaining = buffer.length;
        while (remaining > 0) {
            int location = buffer.length - remaining;
            int count = input.read(buffer, 0 + location, remaining);
            if (EOF == count) { // EOF
                break;
            }
            remaining -= count;
        }
        return buffer.length - remaining;
    }
}

Related

  1. copyLarge(InputStream input, OutputStream output)
  2. copyLarge(InputStream input, OutputStream output)
  3. copyLarge(InputStream input, OutputStream output)
  4. copyLarge(InputStream input, OutputStream output, byte[] buffer)
  5. copyLarge(InputStream input, OutputStream output, byte[] buffer)
  6. copyLarge(InputStream input, OutputStream output, final long inputOffset, final long length, byte[] buffer)
  7. copyLarge(InputStream input, OutputStream output, final long inputOffset, final long length, byte[] buffer)
  8. copyLarge(InputStream input, OutputStream output, long limit)
  9. copyStream(final BufferedReader in, final PrintWriter out, final String[] mapFrom, String[] mapTo)