TrueZIP Kernel 7.0-rc1

de.schlichtherle.truezip.io
Class Streams

java.lang.Object
  extended by de.schlichtherle.truezip.io.Streams

@DefaultAnnotation(value=edu.umd.cs.findbugs.annotations.NonNull.class)
public final class Streams
extends Object

Provides static utility methods for InputStreams and OutputStreams.

Author:
Christian Schlichtherle

Nested Class Summary
private static class Streams.Buffer
          A buffer for I/O.
private static class Streams.InputStreamReaderThreadFactory
          A factory for input stream reader threads.
 
Field Summary
private static ExecutorService executor
           
 
Constructor Summary
private Streams()
          You cannot instantiate this class.
 
Method Summary
private static Streams.Buffer[] allocateBuffers()
           
static void cat(InputStream in, OutputStream out)
          Copies the data from the given input stream to the given output stream without closing them.
static void copy(InputStream in, OutputStream out)
          Copies the data from the given input stream to the given output stream and always closes both streams - even if an exception occurs.
private static void releaseBuffers(Streams.Buffer[] buffers)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

executor

private static final ExecutorService executor
Constructor Detail

Streams

private Streams()
You cannot instantiate this class.

Method Detail

copy

public static void copy(InputStream in,
                        OutputStream out)
                 throws IOException
Copies the data from the given input stream to the given output stream and always closes both streams - even if an exception occurs.

This is a high performance implementation which uses a pooled background thread to fill a FIFO of data buffers which is concurrently flushed by the current thread.

Parameters:
in - the input stream.
out - the output stream.
Throws:
InputException - if copying the data fails because of an IOException in the input stream.
IOException - if copying the data fails because of an IOException in the output stream.

cat

public static void cat(InputStream in,
                       OutputStream out)
                throws IOException
Copies the data from the given input stream to the given output stream without closing them. The name of this method is inspired by the Unix command line utility cat because you could use it to concatenate the contents of multiple streams.

This is a high performance implementation which uses a pooled background thread to fill a FIFO of data buffers which is concurrently flushed by the current thread.

Parameters:
in - the input stream.
out - the output stream.
Throws:
InputException - if copying the data fails because of an IOException in the input stream.
IOException - if copying the data fails because of an IOException in the output stream.

allocateBuffers

private static Streams.Buffer[] allocateBuffers()

releaseBuffers

private static void releaseBuffers(Streams.Buffer[] buffers)

TrueZIP Kernel 7.0-rc1

Copyright © 2005-2011 Schlichtherle IT Services. All Rights Reserved.