com.Ostermiller.util Java Utilities


com.Ostermiller.util
Class NoCloseInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by com.Ostermiller.util.NoCloseInputStream
All Implemented Interfaces:
NoCloseStream, Closeable

public class NoCloseInputStream
extends InputStream
implements NoCloseStream

An input stream with a close method with no effect. More information about this class is available from ostermiller.org.

This class is designed to wrap a normal input stream so that it can be passed to methods that read from it and may erroneously close it. This class is a workaround when the method cannot be modified because it is in a library.

Since:
ostermillerutils 1.01.00
Author:
Stephen Ostermiller http://ostermiller.org/contact.pl?regarding=Java+Utilities

Constructor Summary
NoCloseInputStream(InputStream in)
          Protect a new input stream.
 
Method Summary
 int available()
          
 void close()
          Has no effect.
 void mark(int readlimit)
          
 boolean markSupported()
          
 int read()
          
 int read(byte[] b)
          
 int read(byte[] b, int off, int len)
          
 void reallyClose()
          Actually closes this stream and releases any system resources associated with the stream, as opposed to the close() method, which does nothing.
 void reset()
          
 long skip(long n)
          
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NoCloseInputStream

public NoCloseInputStream(InputStream in)
Protect a new input stream.

Parameters:
in - The input stream that is being protected.
Since:
ostermillerutils 1.01.00
Method Detail

read

public int read()
         throws IOException

Specified by:
read in class InputStream
Throws:
IOException

read

public int read(byte[] b)
         throws IOException

Overrides:
read in class InputStream
Throws:
IOException

read

public int read(byte[] b,
                int off,
                int len)
         throws IOException

Overrides:
read in class InputStream
Throws:
IOException

skip

public long skip(long n)
          throws IOException

Overrides:
skip in class InputStream
Throws:
IOException

available

public int available()
              throws IOException

Overrides:
available in class InputStream
Throws:
IOException

close

public void close()
           throws IOException
Has no effect.

Specified by:
close in interface Closeable
Overrides:
close in class InputStream
Throws:
IOException
Since:
ostermillerutils 1.01.00
See Also:
reallyClose()

mark

public void mark(int readlimit)

Overrides:
mark in class InputStream

reset

public void reset()
           throws IOException

Overrides:
reset in class InputStream
Throws:
IOException

markSupported

public boolean markSupported()

Overrides:
markSupported in class InputStream

reallyClose

public void reallyClose()
                 throws IOException
Actually closes this stream and releases any system resources associated with the stream, as opposed to the close() method, which does nothing.

Specified by:
reallyClose in interface NoCloseStream
Throws:
IOException - if an I/O error occurs.

com.Ostermiller.util Java Utilities


Copyright © 2001-2012 by Stephen Ostermiller