Class ArjArchiveInputStream
java.lang.Object
java.io.InputStream
org.apache.commons.compress.archivers.ArchiveInputStream
org.apache.commons.compress.archivers.arj.ArjArchiveInputStream
- All Implemented Interfaces:
Closeable
,AutoCloseable
Implements the "arj" archive format as an InputStream.
- Since:
- 1.6
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final int
private static final int
private final String
private InputStream
private LocalFileHeader
private final DataInputStream
private final MainHeader
-
Constructor Summary
ConstructorsConstructorDescriptionArjArchiveInputStream
(InputStream inputStream) Constructs the ArjInputStream, taking ownership of the inputStream that is passed in, and using the CP437 character encoding.ArjArchiveInputStream
(InputStream inputStream, String charsetName) Constructs the ArjInputStream, taking ownership of the inputStream that is passed in. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Whether this stream is able to read the given entry.void
close()
Gets the archive's comment.Gets the archive's recorded name.Returns the next Archive Entry in this Stream.static boolean
matches
(byte[] signature, int length) Checks if the signature matches what is expected for an arj file.int
read
(byte[] b, int off, int len) private int
read16
(DataInputStream dataIn) private int
read32
(DataInputStream dataIn) private int
read8
(DataInputStream dataIn) private void
readExtraData
(int firstHeaderSize, DataInputStream firstHeader, LocalFileHeader localFileHeader) private byte[]
private LocalFileHeader
private MainHeader
private byte[]
readRange
(InputStream in, int len) private String
readString
(DataInputStream dataIn) Methods inherited from class org.apache.commons.compress.archivers.ArchiveInputStream
count, count, getBytesRead, getCount, pushedBackBytes, read
Methods inherited from class java.io.InputStream
available, mark, markSupported, read, readAllBytes, readNBytes, reset, skip, transferTo
-
Field Details
-
ARJ_MAGIC_1
private static final int ARJ_MAGIC_1- See Also:
-
ARJ_MAGIC_2
private static final int ARJ_MAGIC_2- See Also:
-
in
-
charsetName
-
mainHeader
-
currentLocalFileHeader
-
currentInputStream
-
-
Constructor Details
-
ArjArchiveInputStream
Constructs the ArjInputStream, taking ownership of the inputStream that is passed in.- Parameters:
inputStream
- the underlying stream, whose ownership is takencharsetName
- the charset used for file names and comments in the archive. May benull
to use the platform default.- Throws:
ArchiveException
- if an exception occurs while reading
-
ArjArchiveInputStream
Constructs the ArjInputStream, taking ownership of the inputStream that is passed in, and using the CP437 character encoding.- Parameters:
inputStream
- the underlying stream, whose ownership is taken- Throws:
ArchiveException
- if an exception occurs while reading
-
-
Method Details
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classInputStream
- Throws:
IOException
-
read8
- Throws:
IOException
-
read16
- Throws:
IOException
-
read32
- Throws:
IOException
-
readString
- Throws:
IOException
-
readRange
- Throws:
IOException
-
readHeader
- Throws:
IOException
-
readMainHeader
- Throws:
IOException
-
readLocalFileHeader
- Throws:
IOException
-
readExtraData
private void readExtraData(int firstHeaderSize, DataInputStream firstHeader, LocalFileHeader localFileHeader) throws IOException - Throws:
IOException
-
matches
public static boolean matches(byte[] signature, int length) Checks if the signature matches what is expected for an arj file.- Parameters:
signature
- the bytes to checklength
- the number of bytes to check- Returns:
- true, if this stream is an arj archive stream, false otherwise
-
getArchiveName
Gets the archive's recorded name.- Returns:
- the archive's name
-
getArchiveComment
Gets the archive's comment.- Returns:
- the archive's comment
-
getNextEntry
Description copied from class:ArchiveInputStream
Returns the next Archive Entry in this Stream.- Specified by:
getNextEntry
in classArchiveInputStream
- Returns:
- the next entry,
or
null
if there are no more entries - Throws:
IOException
- if the next entry could not be read
-
canReadEntryData
Description copied from class:ArchiveInputStream
Whether this stream is able to read the given entry.Some archive formats support variants or details that are not supported (yet).
- Overrides:
canReadEntryData
in classArchiveInputStream
- Parameters:
ae
- the entry to test- Returns:
- This implementation always returns true.
-
read
- Overrides:
read
in classInputStream
- Throws:
IOException
-