ccs.utils
Class BytePump

java.lang.Object
  extended by ccs.utils.BytePump

public class BytePump
extends java.lang.Object

A very simple class that transfers an enitre InputStream to an OutputStream. Uses a buffer to ensure reasonable efficiency. To transfer only part of the stream, use a DammedInputStream.

See Also:
DammedInputStream

Constructor Summary
BytePump()
           
 
Method Summary
static long transfer(java.io.InputStream in, java.io.OutputStream out, boolean isClose)
          Transfers the input stream to the output stream, using a default buffer size (32K).
static long transfer(java.io.InputStream in, java.io.OutputStream out, int bufsz, boolean isClose)
          Transfers the input stream to the output stream, using a given buffer size.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BytePump

public BytePump()
Method Detail

transfer

public static long transfer(java.io.InputStream in,
                            java.io.OutputStream out,
                            int bufsz,
                            boolean isClose)
                     throws java.io.IOException
Transfers the input stream to the output stream, using a given buffer size.

Parameters:
in - the input stream.
out - the output stream
bufsz - the buffer size
isClose - if true, closes the streams after successful completion (but not if an IOException is thrown).
Returns:
the number of bytes transferred.
Throws:
java.io.IOException - if an I/O error occurs.

transfer

public static long transfer(java.io.InputStream in,
                            java.io.OutputStream out,
                            boolean isClose)
                     throws java.io.IOException
Transfers the input stream to the output stream, using a default buffer size (32K).

Parameters:
in - the input stream.
out - the output stream.
isClose - if true, closes the streams after successful completion (but not if an IOException is thrown).
Returns:
the number of bytes transferred.
Throws:
java.io.IOException - if an I/O error occurs.