Top Description Fields Constructors Methods
org.apache.commons.compress.archivers.arj

public Class ArjArchiveInputStream

extends ArchiveInputStream<ArjArchiveEntry>
Class Inheritance
Imports
java.io.ByteArrayInputStream, .ByteArrayOutputStream, .DataInputStream, .EOFException, .IOException, .InputStream, java.util.ArrayList, java.util.zip.CRC32, org.apache.commons.compress.archivers.ArchiveEntry, .ArchiveException, .ArchiveInputStream, org.apache.commons.compress.utils.BoundedInputStream, .CRC32VerifyingInputStream, .IOUtils

Implements the "arj" archive format as an InputStream.
Since
1.6

Field Summary

Modifier and TypeField and Description
private static final int
private static final int
private InputStream
private LocalFileHeader
private final DataInputStream
private static final String
private final MainHeader

Constructor Summary

AccessConstructor and Description
public
ArjArchiveInputStream(final InputStream
the underlying stream, whose ownership is taken
inputStream
)

Constructs the ArjInputStream, taking ownership of the inputStream that is passed in, and using the CP437 character encoding.

public
ArjArchiveInputStream(final InputStream
the underlying stream, whose ownership is taken
inputStream
,
final String
the charset used for file names and comments in the archive. May be null to use the platform default.
charsetName
)

Constructs the ArjInputStream, taking ownership of the inputStream that is passed in.

Method Summary

Modifier and TypeMethod and Description
public boolean
canReadEntryData(final ArchiveEntry
the entry to test
ae
)

Overrides org.apache.commons.compress.archivers.ArchiveInputStream.canReadEntryData.

Whether this stream is able to read the given entry.
public void
close()

Overrides java.io.FilterInputStream.close.

Implements java.io.Closeable.close.

Closes this input stream and releases any system resources associated with the stream.
public String

Returns:

the archive's comment
getArchiveComment
()

Gets the archive's comment.

public String

Returns:

the archive's name
getArchiveName
()

Gets the archive's recorded name.

public ArjArchiveEntry
getNextEntry()

Implements abstract org.apache.commons.compress.archivers.ArchiveInputStream.getNextEntry.

Gets the next Archive Entry in this Stream.
public static boolean

Returns:

true, if this stream is an arj archive stream, false otherwise
matches
(final byte[]
the bytes to check
signature
,
final int
the number of bytes to check
length
)

Checks if the signature matches what is expected for an arj file.

public int
read(final byte[]
the buffer into which the data is read.
b
,
final int
the start offset in array b at which the data is written.
off
,
final int
the maximum number of bytes to read.
len
)

Overrides java.io.FilterInputStream.read.

Reads up to len bytes of data from this input stream into an array of bytes.
private int
read16(final DataInputStream dataIn)

private int
read32(final DataInputStream dataIn)

private int
read8(final DataInputStream dataIn)

private void
readExtraData(final int firstHeaderSize, final DataInputStream firstHeader, final LocalFileHeader localFileHeader)

private byte[]
private LocalFileHeader
private MainHeader
private byte[]
readRange(final InputStream in, final int len)

private String
Inherited from org.apache.commons.compress.archivers.ArchiveInputStream:
countcountgetBytesReadgetCharsetgetCountpushedBackBytesread

Field Detail

ARJ_MAGIC_1back to summary
private static final int ARJ_MAGIC_1
ARJ_MAGIC_2back to summary
private static final int ARJ_MAGIC_2
currentInputStreamback to summary
private InputStream currentInputStream
currentLocalFileHeaderback to summary
private LocalFileHeader currentLocalFileHeader
disback to summary
private final DataInputStream dis
ENCODING_NAMEback to summary
private static final String ENCODING_NAME
mainHeaderback to summary
private final MainHeader mainHeader

Constructor Detail

ArjArchiveInputStreamback to summary
public ArjArchiveInputStream(final InputStream inputStream) throws ArchiveException

Constructs the ArjInputStream, taking ownership of the inputStream that is passed in, and using the CP437 character encoding.

Parameters
inputStream:InputStream

the underlying stream, whose ownership is taken

Exceptions
ArchiveException:
if an exception occurs while reading
ArjArchiveInputStreamback to summary
public ArjArchiveInputStream(final InputStream inputStream, final String charsetName) throws ArchiveException

Constructs the ArjInputStream, taking ownership of the inputStream that is passed in.

Parameters
inputStream:InputStream

the underlying stream, whose ownership is taken

charsetName:String

the charset used for file names and comments in the archive. May be null to use the platform default.

Exceptions
ArchiveException:
if an exception occurs while reading

Method Detail

canReadEntryDataback to summary
public boolean canReadEntryData(final ArchiveEntry ae)

Overrides org.apache.commons.compress.archivers.ArchiveInputStream.canReadEntryData.

Doc from org.apache.commons.compress.archivers.ArchiveInputStream.canReadEntryData.

Whether this stream is able to read the given entry.

Some archive formats support variants or details that are not supported (yet).

Parameters
ae:ArchiveEntry

the entry to test

Returns:boolean

This implementation always returns true.

Annotations
@Override
closeback to summary
public void close() throws IOException

Overrides java.io.FilterInputStream.close.

Implements java.io.Closeable.close.

Doc from java.io.FilterInputStream.close.

Closes this input stream and releases any system resources associated with the stream.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.
getArchiveCommentback to summary
public String getArchiveComment()

Gets the archive's comment.

Returns:String

the archive's comment

getArchiveNameback to summary
public String getArchiveName()

Gets the archive's recorded name.

Returns:String

the archive's name

getNextEntryback to summary
public ArjArchiveEntry getNextEntry() throws IOException

Implements abstract org.apache.commons.compress.archivers.ArchiveInputStream.getNextEntry.

Doc from org.apache.commons.compress.archivers.ArchiveInputStream.getNextEntry.

Gets the next Archive Entry in this Stream.

Returns:ArjArchiveEntry

the next entry, or null if there are no more entries

Annotations
@Override
Exceptions
IOException:
if the next entry could not be read
matchesback to summary
public static boolean matches(final byte[] signature, final int length)

Checks if the signature matches what is expected for an arj file.

Parameters
signature:byte[]

the bytes to check

length:int

the number of bytes to check

Returns:boolean

true, if this stream is an arj archive stream, false otherwise

readback to summary
public int read(final byte[] b, final int off, final int len) throws IOException

Overrides java.io.FilterInputStream.read.

Doc from java.io.FilterInputStream.read.

Reads up to len bytes of data from this input stream into an array of bytes. If len is not zero, the method blocks until some input is available; otherwise, no bytes are read and 0 is returned.

Parameters
b:byte[]

the buffer into which the data is read.

off:int

the start offset in array b at which the data is written.

len:int

the maximum number of bytes to read.

Returns:int

the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.
read16back to summary
private int read16(final DataInputStream dataIn) throws IOException
read32back to summary
private int read32(final DataInputStream dataIn) throws IOException
read8back to summary
private int read8(final DataInputStream dataIn) throws IOException
readExtraDataback to summary
private void readExtraData(final int firstHeaderSize, final DataInputStream firstHeader, final LocalFileHeader localFileHeader) throws IOException
readHeaderback to summary
private byte[] readHeader() throws IOException
readLocalFileHeaderback to summary
private LocalFileHeader readLocalFileHeader() throws IOException
readMainHeaderback to summary
private MainHeader readMainHeader() throws IOException
readRangeback to summary
private byte[] readRange(final InputStream in, final int len) throws IOException
readStringback to summary
private String readString(final DataInputStream dataIn) throws IOException