Java InputStream to OutputStream copyStreams(InputStream inputStream, OutputStream outputStream)

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

Description

Copy the input stream to the output stream

License

Open Source License

Parameter

Parameter Description
inputStream InputStream
outputStream OutputStream

Exception

Parameter Description
IOException if I/O exception

Declaration

public static void copyStreams(InputStream inputStream, OutputStream outputStream) throws IOException 

Method Source Code

//package com.java2s;

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

import java.io.OutputStream;

public class Main {
    /**//from  w  ww. j a v  a 2  s  . c o m
     * Copy the input stream to the output stream
     * 
     * @param inputStream InputStream
     * @param outputStream OutputStream
     * @throws IOException if I/O exception
     */
    public static void copyStreams(InputStream inputStream, OutputStream outputStream) throws IOException {
        byte[] buffer = new byte[1024];
        int length;

        while ((length = inputStream.read(buffer)) >= 0) {
            outputStream.write(buffer, 0, length);
        }
    }
}

Related

  1. copyStreams(InputStream in, OutputStream out)
  2. copyStreams(InputStream in, OutputStream out)
  3. copyStreams(InputStream in, OutputStream out)
  4. copyStreams(InputStream in, OutputStream out, int buf)
  5. copyStreams(InputStream input, OutputStream output)
  6. copyStreams(InputStream is, OutputStream os)
  7. copyStreams(InputStream source, OutputStream destination)
  8. copyStreams(InputStream source, OutputStream target)
  9. copyStreamSafely(InputStream in, ByteArrayOutputStream os)