Java InputStream to OutputStream copyStream(InputStream in, OutputStream out, int bufsize)

Here you can find the source of copyStream(InputStream in, OutputStream out, int bufsize)

Description

Copies everything from in to out

License

Open Source License

Parameter

Parameter Description
in the InputStream to copy from
out the OutputStream to copy to
bufsize buffer size

Declaration

public static void copyStream(InputStream in, OutputStream out, int bufsize) throws IOException 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

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

public class Main {
    /**/*from   w  ww  .  jav a 2  s  .c  om*/
     * Copies everything from <code>in</code> to <code>out</code>
     * 
     * @param in
     *            the {@link InputStream} to copy from
     * @param out
     *            the {@link OutputStream} to copy to
     * @param bufsize
     *            buffer size
     */
    public static void copyStream(InputStream in, OutputStream out, int bufsize) throws IOException {
        byte[] buffer = new byte[bufsize];
        int len;
        while ((len = in.read(buffer)) != -1)
            out.write(buffer, 0, len);
    }
}

Related

  1. copyStream(InputStream in, OutputStream out)
  2. copyStream(InputStream in, OutputStream out)
  3. copyStream(InputStream in, OutputStream out, boolean closeIn, boolean closeOut)
  4. copyStream(InputStream in, OutputStream out, boolean closeOut)
  5. copyStream(InputStream in, OutputStream out, int bufferSize)
  6. copyStream(InputStream in, OutputStream out, int len)
  7. copyStream(InputStream in, OutputStream out, JarEntry entry)
  8. copyStream(InputStream in, OutputStream out, long maxLen)
  9. copyStream(InputStream in, OutputStream out, String end)