Java InputStream to OutputStream copyStreams(InputStream is, OutputStream os)

Here you can find the source of copyStreams(InputStream is, OutputStream os)

Description

copy is to os.

License

Open Source License

Parameter

Parameter Description
is a parameter
os a parameter

Exception

Parameter Description
IOException thrown if copy fails

Declaration

public static void copyStreams(InputStream is, OutputStream os) throws IOException 

Method Source Code

//package com.java2s;
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt

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

public class Main {
    /**//from  w  w w  .  j  av a2  s . c  o m
     * 
     */
    private static final int COPY_BUF_SIZE = 512;

    /**
     * copy is to os.
     * 
     * @param is
     * @param os
     * @throws IOException thrown if copy fails
     */
    public static void copyStreams(InputStream is, OutputStream os) throws IOException {
        byte[] bytearray = new byte[COPY_BUF_SIZE];
        int len = 0;
        while ((len = is.read(bytearray)) != -1) {
            os.write(bytearray, 0, len);
        }
    }
}

Related

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