Java InputStream to OutputStream copyStream(final InputStream src, OutputStream dest)

Here you can find the source of copyStream(final InputStream src, OutputStream dest)

Description

Writes the content of an input stream to an output stream

License

Open Source License

Exception

Parameter Description
IOException an exception

Declaration

public static void copyStream(final InputStream src, OutputStream dest)
        throws IOException 

Method Source Code

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

public class Main {
    /**//from w w w. ja v  a 2  s.  c o m
     * Writes the content of an input stream to an output stream
     *
     * @throws IOException
     */
    public static void copyStream(final InputStream src, OutputStream dest)
            throws IOException {
        byte[] buffer = new byte[1024];
        int read = 0;
        while ((read = src.read(buffer)) > -1) {
            dest.write(buffer, 0, read);
        }
        dest.flush();
    }
}

Related

  1. copyStream(final InputStream inputStream, final OutputStream outputStream)
  2. copyStream(final InputStream is, final OutputStream os)
  3. copyStream(final InputStream is, final OutputStream os)
  4. copyStream(final InputStream is, final OutputStream out, final Long amount, final int bufferSize)
  5. copyStream(final InputStream source, final OutputStream target)
  6. copyStream(final OutputStream to, final InputStream from)
  7. copyStream(InputStream fis, OutputStream fos)
  8. copyStream(InputStream from, OutputStream to)
  9. copyStream(InputStream in, boolean closeIn, OutputStream out, boolean closeOut)