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

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

Description

copy Stream

License

Apache License

Declaration

public static void copyStream(InputStream is, OutputStream os) throws IOException 

Method Source Code


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

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

public class Main {
    public static void copyStream(InputStream is, OutputStream os) throws IOException {
        byte[] buf = new byte[4096];
        BufferedInputStream bis = new BufferedInputStream(is);
        BufferedOutputStream bos = new BufferedOutputStream(os);

        int s;//from  w w  w.  ja va  2  s. c o m
        try {
            while ((s = bis.read(buf)) > 0) {
                bos.write(buf, 0, s);
            }
        } finally {
            try {
                bos.flush();
            } catch (Exception var11) {
                ;
            }

        }

    }
}

Related

  1. copyStream(InputStream inputStream, OutputStream outputStream)
  2. copyStream(InputStream inputStream, OutputStream outputStream)
  3. copyStream(InputStream inStream, OutputStream outStream)
  4. copyStream(InputStream inStream, OutputStream outStream)
  5. copyStream(InputStream is, OutputStream os)
  6. copyStream(InputStream is, OutputStream os)
  7. copyStream(InputStream is, OutputStream os)
  8. CopyStream(InputStream is, OutputStream os)
  9. copyStream(InputStream is, OutputStream os)