Java InputStream to OutputStream copyStreams(InputStream in, OutputStream out)

Here you can find the source of copyStreams(InputStream in, OutputStream out)

Description

Copy all data from in to out in 4096 byte chunks.

License

Apache License

Declaration

public static void copyStreams(InputStream in, OutputStream out) 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 {
    /**//from   www.ja v a 2 s .  com
     * Copy all data from in to out in 4096 byte chunks.
     */
    public static void copyStreams(InputStream in, OutputStream out) throws IOException {
        if (in == null || out == null) {
            throw new IllegalArgumentException();
        }
        final byte[] buffer = new byte[4096];
        int len;
        while (-1 != (len = in.read(buffer, 0, buffer.length))) {
            out.write(buffer, 0, len);
        }
    }
}

Related

  1. copyStreams(final InputStream in, final OutputStream out)
  2. copyStreams(final InputStream input, final OutputStream output)
  3. copyStreams(InputStream from, OutputStream to, int blockSize)
  4. copyStreams(InputStream in, OutputStream out)
  5. copyStreams(InputStream in, OutputStream out)
  6. copyStreams(InputStream in, OutputStream out, int buf)
  7. copyStreams(InputStream input, OutputStream output)
  8. copyStreams(InputStream inputStream, OutputStream outputStream)
  9. copyStreams(InputStream is, OutputStream os)