Class TapeInputStream
java.lang.Object
java.io.InputStream
java.io.FilterInputStream
org.apache.commons.compress.archivers.dump.TapeInputStream
- All Implemented Interfaces:
Closeable
,AutoCloseable
Filter stream that mimics a physical tape drive capable of compressing
the data stream.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate byte[]
private int
private long
private int
private boolean
private int
private static final int
Fields inherited from class java.io.FilterInputStream
in
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
void
close()
Close the input stream.long
Get number of bytes read.byte[]
peek()
Peek at the next record from the input stream and return the data.int
read()
int
read
(byte[] b, int off, int len) private void
readBlock
(boolean decompress) Read next block.private void
readFully
(byte[] b, int off, int len) Read bufferprivate byte[]
readRange
(int len) byte[]
Read a record from the input stream and return the data.void
resetBlockSize
(int recsPerBlock, boolean isCompressed) Set the DumpArchive Buffer's block size.long
skip
(long len) Skip bytes.Methods inherited from class java.io.FilterInputStream
mark, markSupported, read, reset
Methods inherited from class java.io.InputStream
readAllBytes, readNBytes, transferTo
-
Field Details
-
blockBuffer
private byte[] blockBuffer -
currBlkIdx
private int currBlkIdx -
blockSize
private int blockSize -
RECORD_SIZE
private static final int RECORD_SIZE- See Also:
-
readOffset
private int readOffset -
isCompressed
private boolean isCompressed -
bytesRead
private long bytesRead
-
-
Constructor Details
-
TapeInputStream
Constructor
-
-
Method Details
-
resetBlockSize
Set the DumpArchive Buffer's block size. We need to sync the block size with the dump archive's actual block size since compression is handled at the block level.- Parameters:
recsPerBlock
- records per blockisCompressed
- true if the archive is compressed- Throws:
IOException
- more than one block has been readIOException
- there was an error reading additional blocks.IOException
- recsPerBlock is smaller than 1
-
available
- Overrides:
available
in classFilterInputStream
- Throws:
IOException
- See Also:
-
read
- Overrides:
read
in classFilterInputStream
- Throws:
IOException
- See Also:
-
read
reads the full given length unless EOF is reached.
- Overrides:
read
in classFilterInputStream
- Parameters:
len
- length to read, must be a multiple of the stream's record size- Throws:
IOException
-
skip
Skip bytes. Same as read but without the arraycopy.skips the full given length unless EOF is reached.
- Overrides:
skip
in classFilterInputStream
- Parameters:
len
- length to read, must be a multiple of the stream's record size- Throws:
IOException
-
close
Close the input stream.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classFilterInputStream
- Throws:
IOException
- on error
-
peek
Peek at the next record from the input stream and return the data.- Returns:
- The record data.
- Throws:
IOException
- on error
-
readRecord
Read a record from the input stream and return the data.- Returns:
- The record data.
- Throws:
IOException
- on error
-
readBlock
Read next block. All decompression is handled here.- Parameters:
decompress
- if false the buffer will not be decompressed. This is an optimization for longer seeks.- Throws:
IOException
-
readFully
Read buffer- Throws:
IOException
-
readRange
- Throws:
IOException
-
getBytesRead
public long getBytesRead()Get number of bytes read.
-