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 intprivate longprivate intprivate booleanprivate intprivate static final intFields inherited from class java.io.FilterInputStream
in -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintvoidclose()Close the input stream.longGet number of bytes read.byte[]peek()Peek at the next record from the input stream and return the data.intread()intread(byte[] b, int off, int len) private voidreadBlock(boolean decompress) Read next block.private voidreadFully(byte[] b, int off, int len) Read bufferprivate byte[]readRange(int len) byte[]Read a record from the input stream and return the data.voidresetBlockSize(int recsPerBlock, boolean isCompressed) Set the DumpArchive Buffer's block size.longskip(long len) Skip bytes.Methods inherited from class java.io.FilterInputStream
mark, markSupported, read, resetMethods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, skipNBytes, 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:
availablein classFilterInputStream- Throws:
IOException- See Also:
-
read
- Overrides:
readin classFilterInputStream- Throws:
IOException- See Also:
-
read
reads the full given length unless EOF is reached.
- Overrides:
readin 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:
skipin 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:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein 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.
-