Package org.apache.commons.io.input
Class UnsynchronizedReader
- java.lang.Object
-
- java.io.Reader
-
- org.apache.commons.io.input.UnsynchronizedReader
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,java.lang.Readable
- Direct Known Subclasses:
UnsynchronizedBufferedReader
public abstract class UnsynchronizedReader extends java.io.ReaderAReaderwithout any of the superclass' synchronization.- Since:
- 2.17.0
-
-
Field Summary
Fields Modifier and Type Field Description private booleanclosedWhetherclose()completed successfully.private static intMAX_SKIP_BUFFER_SIZEThe maximum skip-buffer size.private char[]skipBufferThe skip buffer, defaults to null until allocated inskip(long).
-
Constructor Summary
Constructors Constructor Description UnsynchronizedReader()Constructs a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) voidcheckOpen()Checks if this instance is closed and throws an IOException if so.voidclose()booleanisClosed()Tests whether this instance is closed; ifclose()completed successfully.voidsetClosed(boolean closed)Sets whether this instance is closed.longskip(long n)Skips characters by reading from this instance.
-
-
-
Field Detail
-
MAX_SKIP_BUFFER_SIZE
private static final int MAX_SKIP_BUFFER_SIZE
The maximum skip-buffer size.- See Also:
- Constant Field Values
-
closed
private boolean closed
Whetherclose()completed successfully.
-
skipBuffer
private char[] skipBuffer
The skip buffer, defaults to null until allocated inskip(long).
-
-
Method Detail
-
checkOpen
void checkOpen() throws java.io.IOExceptionChecks if this instance is closed and throws an IOException if so.- Throws:
java.io.IOException- if this instance is closed.
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Specified by:
closein classjava.io.Reader- Throws:
java.io.IOException
-
isClosed
public boolean isClosed()
Tests whether this instance is closed; ifclose()completed successfully.- Returns:
- whether this instance is closed.
-
setClosed
public void setClosed(boolean closed)
Sets whether this instance is closed.- Parameters:
closed- whether this instance is closed.
-
skip
public long skip(long n) throws java.io.IOExceptionSkips characters by reading from this instance. This method will block until:- some characters are available,
- an I/O error occurs, or
- the end of the stream is reached.
- Overrides:
skipin classjava.io.Reader- Parameters:
n- The number of characters to skip.- Returns:
- The number of characters actually skipped.
- Throws:
java.lang.IllegalArgumentException- Ifnis negative.java.io.IOException- If an I/O error occurs.
-
-