com.Ostermiller.util Java Utilities


com.Ostermiller.util
Class NoCloseReader

java.lang.Object
  extended by java.io.Reader
      extended by com.Ostermiller.util.NoCloseReader
All Implemented Interfaces:
NoCloseStream, Closeable, Readable

public class NoCloseReader
extends Reader
implements NoCloseStream

A reader which a close method with no effect. More information about this class is available from ostermiller.org.

This class is designed to wrap a normal reader 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
NoCloseReader(Reader in)
          Protect a new reader.
 
Method Summary
 void close()
          Has no effect.
 void mark(int readlimit)
          
 boolean markSupported()
          
 int read()
          
 int read(char[] cbuf)
          
 int read(char[] cbuf, int off, int len)
          
 boolean ready()
          
 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.io.Reader
read
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NoCloseReader

public NoCloseReader(Reader in)
Protect a new reader.

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

read

public int read()
         throws IOException

Overrides:
read in class Reader
Throws:
IOException

read

public int read(char[] cbuf)
         throws IOException

Overrides:
read in class Reader
Throws:
IOException

read

public int read(char[] cbuf,
                int off,
                int len)
         throws IOException

Specified by:
read in class Reader
Throws:
IOException

skip

public long skip(long n)
          throws IOException

Overrides:
skip in class Reader
Throws:
IOException

ready

public boolean ready()
              throws IOException

Overrides:
ready in class Reader
Throws:
IOException

close

public void close()
           throws IOException
Has no effect.

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

mark

public void mark(int readlimit)
          throws IOException

Overrides:
mark in class Reader
Throws:
IOException

reset

public void reset()
           throws IOException

Overrides:
reset in class Reader
Throws:
IOException

markSupported

public boolean markSupported()

Overrides:
markSupported in class Reader

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