Java OutputStream Write writeStreamToStream(InputStream input, OutputStream output)

Here you can find the source of writeStreamToStream(InputStream input, OutputStream output)

Description

Send all bytes from the input stream to the output stream.

License

Open Source License

Parameter

Parameter Description
input The input bytes.
output Where the bytes should be written.

Declaration

public static void writeStreamToStream(InputStream input,
        OutputStream output) throws IOException 

Method Source Code

//package com.java2s;
import java.io.*;

public class Main {
    /**//ww  w .  j  a  va  2 s  .co  m
     * Send all bytes from the input stream to the output stream.
     *
     * @param input
     *          The input bytes.
     * @param output
     *          Where the bytes should be written.
     */
    public static void writeStreamToStream(InputStream input,
            OutputStream output) throws IOException {
        byte[] buffer = new byte[4096];
        while (true) {
            int len = input.read(buffer);
            if (len == -1) {
                break;
            }
            output.write(buffer, 0, len);
        }
    }
}

Related

  1. writeStreamFromString(String serializePath)
  2. writeStreamInFile(File f, InputStream in)
  3. writeStreamText(OutputStream out, String text)
  4. writeStreamToArray(InputStream stream)
  5. writeStreamToStream(InputStream in, OutputStream out)
  6. writeStreamToStream(InputStream inputStream, OutputStream outputStream)