it.could.util
Class StreamTools

java.lang.Object
  extended byit.could.util.StreamTools

public final class StreamTools
extends Object

An utility class providing various static methods operating on input and output streams.

Author:
Pier Fumagalli

Method Summary
static long copy(InputStream in, OutputStream out)
          Copy every byte from the specified InputStream to the specifed OutputStream and then close both of them.
static long copy(InputStream in, OutputStream out, boolean close)
          Copy every byte from the specified InputStream to the specifed OutputStream and then optionally close both of them.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

copy

public static long copy(InputStream in,
                        OutputStream out)
                 throws IOException

Copy every byte from the specified InputStream to the specifed OutputStream and then close both of them.

This method is equivalent to a call to the following method: copy(in, out, true).

Parameters:
in - the InputStream to read bytes from.
out - the OutputStream to write bytes to.
Returns:
the number of bytes copied.
Throws:
IOException - if an I/O error occurred copying the data.

copy

public static long copy(InputStream in,
                        OutputStream out,
                        boolean close)
                 throws IOException

Copy every byte from the specified InputStream to the specifed OutputStream and then optionally close both of them.

Parameters:
in - the InputStream to read bytes from.
out - the OutputStream to write bytes to.
close - whether to close the streams or not.
Returns:
the number of bytes copied.
Throws:
IOException - if an I/O error occurred copying the data.