Class ArjArchiveInputStream
- java.lang.Object
-
- java.io.InputStream
-
- org.apache.commons.compress.archivers.ArchiveInputStream
-
- org.apache.commons.compress.archivers.arj.ArjArchiveInputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
public class ArjArchiveInputStream extends ArchiveInputStream
Implements the "arj" archive format as an InputStream.- Since:
- 1.6
-
-
Field Summary
Fields Modifier and Type Field Description private static intARJ_MAGIC_1private static intARJ_MAGIC_2private java.lang.StringcharsetNameprivate java.io.InputStreamcurrentInputStreamprivate LocalFileHeadercurrentLocalFileHeaderprivate java.io.DataInputStreaminprivate MainHeadermainHeader
-
Constructor Summary
Constructors Constructor Description ArjArchiveInputStream(java.io.InputStream inputStream)Constructs the ArjInputStream, taking ownership of the inputStream that is passed in, and using the CP437 character encoding.ArjArchiveInputStream(java.io.InputStream inputStream, java.lang.String charsetName)Constructs the ArjInputStream, taking ownership of the inputStream that is passed in.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancanReadEntryData(ArchiveEntry ae)Whether this stream is able to read the given entry.voidclose()java.lang.StringgetArchiveComment()Gets the archive's comment.java.lang.StringgetArchiveName()Gets the archive's recorded name.ArjArchiveEntrygetNextEntry()Returns the next Archive Entry in this Stream.static booleanmatches(byte[] signature, int length)Checks if the signature matches what is expected for an arj file.intread(byte[] b, int off, int len)private intread16(java.io.DataInputStream dataIn)private intread32(java.io.DataInputStream dataIn)private intread8(java.io.DataInputStream dataIn)private voidreadExtraData(int firstHeaderSize, java.io.DataInputStream firstHeader, LocalFileHeader localFileHeader)private byte[]readHeader()private LocalFileHeaderreadLocalFileHeader()private MainHeaderreadMainHeader()private byte[]readRange(java.io.InputStream in, int len)private java.lang.StringreadString(java.io.DataInputStream dataIn)-
Methods inherited from class org.apache.commons.compress.archivers.ArchiveInputStream
count, count, getBytesRead, getCount, pushedBackBytes, read
-
-
-
-
Field Detail
-
ARJ_MAGIC_1
private static final int ARJ_MAGIC_1
- See Also:
- Constant Field Values
-
ARJ_MAGIC_2
private static final int ARJ_MAGIC_2
- See Also:
- Constant Field Values
-
in
private final java.io.DataInputStream in
-
charsetName
private final java.lang.String charsetName
-
mainHeader
private final MainHeader mainHeader
-
currentLocalFileHeader
private LocalFileHeader currentLocalFileHeader
-
currentInputStream
private java.io.InputStream currentInputStream
-
-
Constructor Detail
-
ArjArchiveInputStream
public ArjArchiveInputStream(java.io.InputStream inputStream, java.lang.String charsetName) throws ArchiveExceptionConstructs 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 benullto use the platform default.- Throws:
ArchiveException- if an exception occurs while reading
-
ArjArchiveInputStream
public ArjArchiveInputStream(java.io.InputStream inputStream) throws ArchiveExceptionConstructs 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 Detail
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.io.InputStream- Throws:
java.io.IOException
-
read8
private int read8(java.io.DataInputStream dataIn) throws java.io.IOException- Throws:
java.io.IOException
-
read16
private int read16(java.io.DataInputStream dataIn) throws java.io.IOException- Throws:
java.io.IOException
-
read32
private int read32(java.io.DataInputStream dataIn) throws java.io.IOException- Throws:
java.io.IOException
-
readString
private java.lang.String readString(java.io.DataInputStream dataIn) throws java.io.IOException- Throws:
java.io.IOException
-
readRange
private byte[] readRange(java.io.InputStream in, int len) throws java.io.IOException- Throws:
java.io.IOException
-
readHeader
private byte[] readHeader() throws java.io.IOException- Throws:
java.io.IOException
-
readMainHeader
private MainHeader readMainHeader() throws java.io.IOException
- Throws:
java.io.IOException
-
readLocalFileHeader
private LocalFileHeader readLocalFileHeader() throws java.io.IOException
- Throws:
java.io.IOException
-
readExtraData
private void readExtraData(int firstHeaderSize, java.io.DataInputStream firstHeader, LocalFileHeader localFileHeader) throws java.io.IOException- Throws:
java.io.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
public java.lang.String getArchiveName()
Gets the archive's recorded name.- Returns:
- the archive's name
-
getArchiveComment
public java.lang.String getArchiveComment()
Gets the archive's comment.- Returns:
- the archive's comment
-
getNextEntry
public ArjArchiveEntry getNextEntry() throws java.io.IOException
Description copied from class:ArchiveInputStreamReturns the next Archive Entry in this Stream.- Specified by:
getNextEntryin classArchiveInputStream- Returns:
- the next entry,
or
nullif there are no more entries - Throws:
java.io.IOException- if the next entry could not be read
-
canReadEntryData
public boolean canReadEntryData(ArchiveEntry ae)
Description copied from class:ArchiveInputStreamWhether this stream is able to read the given entry.Some archive formats support variants or details that are not supported (yet).
- Overrides:
canReadEntryDatain classArchiveInputStream- Parameters:
ae- the entry to test- Returns:
- This implementation always returns true.
-
read
public int read(byte[] b, int off, int len) throws java.io.IOException- Overrides:
readin classjava.io.InputStream- Throws:
java.io.IOException
-
-