net.dpml.util
Class StreamUtils

java.lang.Object
  extended bynet.dpml.util.StreamUtils

public final class StreamUtils
extends Object

Utility class that provides support for stream copy operations.

Version:
1.0.1
Author:
Digital Product Meta Library

Method Summary
static boolean compareStreams(InputStream in1, InputStream in2)
          Compare two streams.
static void copyStream(InputStream src, OutputStream dest, boolean closeStreams)
          Copy a stream.
static void copyStream(NetworkMonitor monitor, URL source, int expected, InputStream src, OutputStream dest, boolean closeStreams)
          Copy a stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

copyStream

public static void copyStream(InputStream src,
                              OutputStream dest,
                              boolean closeStreams)
                       throws IOException,
                              NullArgumentException
Copy a stream.

Parameters:
src - the source input stream
dest - the destination output stream
closeStreams - TRUE if the streams should be closed on completion
Throws:
IOException - if an IO error occurs
NullArgumentException - if src or destination are null

copyStream

public static void copyStream(NetworkMonitor monitor,
                              URL source,
                              int expected,
                              InputStream src,
                              OutputStream dest,
                              boolean closeStreams)
                       throws IOException,
                              NullArgumentException
Copy a stream.

Parameters:
monitor - optional network monitor to log updates
source - the source url
expected - the expected size in bytes
src - the source input stream
dest - the destination output stream
closeStreams - TRUE if the streams should be closed on completion
Throws:
IOException - if an IO error occurs
NullArgumentException - if src or destination are null

compareStreams

public static boolean compareStreams(InputStream in1,
                                     InputStream in2)
                              throws IOException
Compare two streams.

Parameters:
in1 - the first input stream
in2 - the second input stream
Returns:
the equality status
Throws:
IOException - if an IO error occurs