com.dtolabs.utils
Class Streams

java.lang.Object
  extended by com.dtolabs.utils.Streams

public class Streams
extends java.lang.Object

Streams utility class for reading and writing streams


Nested Class Summary
static class Streams.StreamCopyThread
          A simple Thread subclass that performs a stream copy from an InputStream to an OutputStream.
 
Constructor Summary
Streams()
           
 
Method Summary
static void copyStream(java.io.InputStream in, java.io.OutputStream out)
          Read the data from the input stream and copy to the outputstream.
static int copyStreamCount(java.io.InputStream in, java.io.OutputStream out)
          Read the data from the input stream and copy to the outputstream.
static Streams.StreamCopyThread copyStreamThread(java.io.InputStream in, java.io.OutputStream out)
          Return a new thread that will copy an inputstream to an output stream.
static void copyStreamWithFilterSet(java.io.InputStream in, java.io.OutputStream out, org.apache.tools.ant.types.FilterSet set)
          Read the data from the input stream and write to the outputstream, filtering with an Ant FilterSet.
static int copyWriterCount(java.io.Reader in, java.io.Writer out)
          Read the data from the reader and copy to the writer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Streams

public Streams()
Method Detail

copyStream

public static void copyStream(java.io.InputStream in,
                              java.io.OutputStream out)
                       throws java.io.IOException
Read the data from the input stream and copy to the outputstream.

Parameters:
in - inputstream
out - outpustream
Throws:
java.io.IOException - if thrown by underlying io operations

copyStreamCount

public static int copyStreamCount(java.io.InputStream in,
                                  java.io.OutputStream out)
                           throws java.io.IOException
Read the data from the input stream and copy to the outputstream.

Parameters:
in - inputstream
out - outpustream
Returns:
number of bytes copied
Throws:
java.io.IOException - if thrown by underlying io operations

copyWriterCount

public static int copyWriterCount(java.io.Reader in,
                                  java.io.Writer out)
                           throws java.io.IOException
Read the data from the reader and copy to the writer.

Parameters:
in - inputstream
out - outpustream
Returns:
number of bytes copied
Throws:
java.io.IOException - if thrown by underlying io operations

copyStreamThread

public static Streams.StreamCopyThread copyStreamThread(java.io.InputStream in,
                                                        java.io.OutputStream out)
Return a new thread that will copy an inputstream to an output stream. You must start the thread.

Parameters:
in - inputstream
out - outputstream
Returns:
an unstarted Streams.StreamCopyThread

copyStreamWithFilterSet

public static void copyStreamWithFilterSet(java.io.InputStream in,
                                           java.io.OutputStream out,
                                           org.apache.tools.ant.types.FilterSet set)
                                    throws java.io.IOException
Read the data from the input stream and write to the outputstream, filtering with an Ant FilterSet.

Parameters:
in - inputstream
out - outputstream
set - FilterSet to use
Throws:
java.io.IOException - if thrown by underlying io operations