Java InputStream to OutputStream copyStream(final InputStream inputStream, final OutputStream out)

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

Description

copy Stream

License

Apache License

Declaration

public static long copyStream(final InputStream inputStream, final OutputStream out) throws IOException 

Method Source Code


//package com.java2s;
//License from project: Apache License 

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

public class Main {
    public static long copyStream(final InputStream inputStream, final OutputStream out) throws IOException {
        return copyStream(inputStream, out, 10240);
    }/*  w w w .j a  va 2 s  .  co  m*/

    public static long copyStream(final InputStream inputStream, final OutputStream out, final int bufferSize)
            throws IOException {
        long total = 0;
        byte[] buff = new byte[bufferSize];
        int count = inputStream.read(buff);
        while (count > 0) {
            out.write(buff, 0, count);
            total += count;
            count = inputStream.read(buff);
        }
        return total;
    }
}

Related

  1. copyStream(final InputStream in, final OutputStream out)
  2. copyStream(final InputStream in, final OutputStream out)
  3. copyStream(final InputStream in, final OutputStream out, final int bufferSize)
  4. copyStream(final InputStream in, final OutputStream out, int iMax)
  5. copyStream(final InputStream input, final OutputStream output, long count)
  6. copyStream(final InputStream inputStream, final OutputStream outputStream)
  7. copyStream(final InputStream inputStream, final OutputStream outputStream)
  8. copyStream(final InputStream inputStream, final OutputStream outputStream)
  9. copyStream(final InputStream is, final OutputStream os)