Java InputStream to OutputStream copyStream(InputStream in, OutputStream out)

Here you can find the source of copyStream(InputStream in, OutputStream out)

Description

Copy the content of one stream to another.

License

Open Source License

Parameter

Parameter Description
in input stream
out output stream

Exception

Parameter Description
IOException thrown if reading or writing has failed

Declaration

public static void copyStream(InputStream in, OutputStream out) throws IOException 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.*;

public class Main {
    /**//from  ww  w .  j a  v  a  2  s  . com
     * Copy the content of one stream to another.
     *
     * @param in input stream
     * @param out output stream
     * @throws IOException thrown if reading or writing has failed
     */
    public static void copyStream(InputStream in, OutputStream out) throws IOException {
        byte[] bytes = new byte[1024];
        int len;
        while ((len = in.read(bytes)) != -1)
            out.write(bytes, 0, len);
    }
}

Related

  1. copyStream(InputStream in, OutputStream out)
  2. copyStream(InputStream in, OutputStream out)
  3. copyStream(InputStream in, OutputStream out)
  4. copyStream(InputStream in, OutputStream out)
  5. copyStream(InputStream in, OutputStream out)
  6. copyStream(InputStream in, OutputStream out)
  7. copyStream(InputStream in, OutputStream out)
  8. copyStream(InputStream in, OutputStream out)
  9. copyStream(InputStream in, OutputStream out)