Here you can find the source of writeStreamToStream(InputStream input, OutputStream output)
Parameter | Description |
---|---|
input | The input bytes. |
output | Where the bytes should be written. |
public static void writeStreamToStream(InputStream input, OutputStream output) throws IOException
//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); } } }