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

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

Description

copy Stream

License

Open Source License

Declaration

public static void copyStream(OutputStream out, InputStream in, int bufsz) 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 {
    private static final int BUFSZ = 8196;

    public static void copyStream(OutputStream out, InputStream in, int bufsz) throws IOException {
        byte[] buf = new byte[bufsz];
        int n = 0;
        while ((n = in.read(buf)) > 0) {
            out.write(buf, 0, n);/*from ww w .j  av  a 2s.c  om*/
        }
    }

    public static void copyStream(OutputStream out, InputStream in) throws IOException {
        copyStream(out, in, BUFSZ);
    }
}

Related

  1. CopyStream(InputStream sSource, OutputStream sTarget)
  2. copyStream(int bufferSize, InputStream in, OutputStream out, boolean canStop)
  3. copyStream(java.io.InputStream in, java.io.OutputStream out)
  4. copyStream(java.io.InputStream inputStream, java.io.OutputStream outputStream)
  5. copyStream(java.io.InputStream src, java.io.OutputStream dest)
  6. copyStream(OutputStream outStream, InputStream inStream)
  7. copyStream(Reader input, Writer output)
  8. copyStreamAndClose(InputStream is, OutputStream os)
  9. copyStreamAndClose(InputStream is, OutputStream os)