Package com.dtolabs.utils
Class Streams
- java.lang.Object
-
- com.dtolabs.utils.Streams
-
public class Streams extends java.lang.ObjectStreams utility class for reading and writing streams
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classStreams.StreamCopyThreadA simple Thread subclass that performs a stream copy from an InputStream to an OutputStream.
-
Constructor Summary
Constructors Constructor Description Streams()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static longcopyStream(java.io.InputStream in, java.io.OutputStream out)Read the data from the input stream and copy to the outputstream.static intcopyStreamCount(java.io.InputStream in, java.io.OutputStream out)Read the data from the input stream and copy to the outputstream.static Streams.StreamCopyThreadcopyStreamThread(java.io.InputStream in, java.io.OutputStream out)Return a new thread that will copy an inputstream to an output stream.static Streams.StreamCopyThreadcopyStreamThread(java.io.InputStream in, java.io.OutputStream out, java.lang.Runnable finalizer)Return a new thread that will copy an inputstream to an output stream.static intcopyWriterCount(java.io.Reader in, java.io.Writer out)Read the data from the reader and copy to the writer.
-
-
-
Method Detail
-
copyStream
public static long copyStream(java.io.InputStream in, java.io.OutputStream out) throws java.io.IOExceptionRead the data from the input stream and copy to the outputstream.- Parameters:
in- inputstreamout- outpustream- Returns:
- bytes copied
- 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.IOExceptionRead the data from the input stream and copy to the outputstream.- Parameters:
in- inputstreamout- 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.IOExceptionRead the data from the reader and copy to the writer.- Parameters:
in- inputstreamout- 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- inputstreamout- outputstream- Returns:
- an unstarted
Streams.StreamCopyThread
-
copyStreamThread
public static Streams.StreamCopyThread copyStreamThread(java.io.InputStream in, java.io.OutputStream out, java.lang.Runnable finalizer)
Return a new thread that will copy an inputstream to an output stream. You must start the thread.- Parameters:
in- inputstreamout- outputstreamfinalizer- runnable to execute after the stream is copied or an exception occurred- Returns:
- an unstarted
Streams.StreamCopyThread
-
-