Java OutputStream Write writeStreamToStream(InputStream inputStream, OutputStream outputStream)

Here you can find the source of writeStreamToStream(InputStream inputStream, OutputStream outputStream)

Description

write Stream To Stream

License

Apache License

Declaration

private static void writeStreamToStream(InputStream inputStream, OutputStream outputStream) 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 {
    private static void writeStreamToStream(InputStream inputStream, OutputStream outputStream) throws IOException {

        BufferedInputStream bis = new BufferedInputStream(inputStream);
        BufferedOutputStream bos = new BufferedOutputStream(outputStream);
        try {/*from   w  w  w.  j  a  v  a  2  s .c o  m*/
            int i = 0;
            while ((i = bis.read()) != -1) {
                bos.write(i);
            }
        } finally {
            if (bis != null) {
                bis.close();
            }
            if (bos != null) {
                bos.close();
            }
        }
    }
}

Related

  1. writeStreamInFile(File f, InputStream in)
  2. writeStreamText(OutputStream out, String text)
  3. writeStreamToArray(InputStream stream)
  4. writeStreamToStream(InputStream in, OutputStream out)
  5. writeStreamToStream(InputStream input, OutputStream output)