Java InputStream to OutputStream copyStream(InputStream is, OutputStream os, boolean closeInput)

Here you can find the source of copyStream(InputStream is, OutputStream os, boolean closeInput)

Description

copy Stream

License

Open Source License

Declaration

public static void copyStream(InputStream is, OutputStream os,
            boolean closeInput) 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 {
    public static void copyStream(InputStream is, OutputStream os,
            boolean closeInput) throws IOException {
        try {//  w  ww . j a  v  a 2s  .c om
            byte[] bytes = new byte[4096];
            int numBytes;
            while ((numBytes = is.read(bytes)) != -1) {
                os.write(bytes, 0, numBytes);
            }
        } finally {
            if (closeInput) {
                is.close();
            }
        }
    }
}

Related

  1. copyStream(InputStream is, OutputStream os)
  2. copyStream(InputStream is, OutputStream os)
  3. copyStream(InputStream is, OutputStream os)
  4. copyStream(InputStream is, OutputStream os)
  5. copyStream(InputStream is, OutputStream os)
  6. copyStream(InputStream is, OutputStream os, int bufferSize)
  7. copyStream(InputStream is, OutputStream os, long maxLength)
  8. copyStream(InputStream source, OutputStream dest)
  9. copyStream(InputStream source, OutputStream dest)