Class SkipShieldingInputStream
- java.lang.Object
-
- java.io.InputStream
-
- java.io.FilterInputStream
-
- org.apache.commons.compress.utils.SkipShieldingInputStream
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
public class SkipShieldingInputStream extends java.io.FilterInputStream
A wrapper that overwritesskip(long)
and delegates toFilterInputStream.read()
instead.Some implementations of
InputStream
implementInputStream.skip(long)
in a way that throws an exception if the stream is not seekable -System.in
is known to behave that way. For such a stream it is impossible to invoke skip at all and you have to read from the stream (and discard the data read) instead. Skipping is potentially much faster than reading so we do want to invokeskip
when possible. We provide this class so you can wrap your ownInputStream
in it if you encounter problems withskip
throwing an excpetion.- Since:
- 1.17
-
-
Field Summary
Fields Modifier and Type Field Description private static byte[]
SKIP_BUFFER
private static int
SKIP_BUFFER_SIZE
-
Constructor Summary
Constructors Constructor Description SkipShieldingInputStream(java.io.InputStream in)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
skip(long n)
-
Methods inherited from class java.io.FilterInputStream
available, close, mark, markSupported, read, read, read, reset
-
-
-
-
Field Detail
-
SKIP_BUFFER_SIZE
private static final int SKIP_BUFFER_SIZE
- See Also:
- Constant Field Values
-
SKIP_BUFFER
private static final byte[] SKIP_BUFFER
-
-