com.gc.iotools.stream.is
Class CloseOnceInputStream<T>

java.lang.Object
  extended by java.io.InputStream
      extended by java.io.FilterInputStream
          extended by com.gc.iotools.stream.is.CloseOnceInputStream<T>
All Implemented Interfaces:
Closeable

public class CloseOnceInputStream<T>
extends FilterInputStream

A CloseOnceInputStream contains some other input stream, which it uses as its basic source of data. The class CloseOnceInputStream pass all requests to the contained input stream, except the close() method that is passed only one time to the underlying stream.

Multiple invocation of the close() method will result in only one invocation of the same method on the underlying stream. This is useful with some buggy InputStream that don't allow close() to be called multiple times.

Since:
1.2.6
Author:
dvd.smnt

Field Summary
 
Fields inherited from class java.io.FilterInputStream
in
 
Constructor Summary
CloseOnceInputStream(InputStream source)
           
 
Method Summary
 void close()
           Multiple invocation of this method will result in only one invocation of the close() on the underlying stream.
 int getCloseCount()
          Deprecated. use DiagnosticInputStream instead.
 T getWrappedInputStream()
           Returns the wrapped (original) InputStream passed in the constructor.
 
Methods inherited from class java.io.FilterInputStream
available, mark, markSupported, read, read, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CloseOnceInputStream

public CloseOnceInputStream(InputStream source)
Method Detail

close

public void close()
           throws IOException

Multiple invocation of this method will result in only one invocation of the close() on the underlying stream.

Specified by:
close in interface Closeable
Overrides:
close in class FilterInputStream
Throws:
IOException - Exception thrown if some error happens into the underlying stream.

getCloseCount

public int getCloseCount()
Deprecated. use DiagnosticInputStream instead.

Returns the number of time that close was called.

Returns:
See Also:
com.gc.iotools.stream.is.inspection.DiagnosticInputStream.java

getWrappedInputStream

public T getWrappedInputStream()

Returns the wrapped (original) InputStream passed in the constructor.

Returns:
The original InputStream passed in the constructor


Copyright © 2008-2009. All Rights Reserved.