Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.commons.compress.archivers
Class ArchiveInputStream

    java.lang.Object
      java.io.InputStream
          org.apache.commons.compress.archivers.ArchiveInputStream

All Implemented Interfaces:
  Closeable

Direct Known Subclasses:
  ArArchiveInputStream, CpioArchiveInputStream, TarArchiveInputStream, ZipArchiveInputStream

    public abstract class ArchiveInputStream

extends InputStream

Archive input streams MUST override the `InputStream.read(byte[], int, int)` - or `read()` - method so that reading from the stream generates EOF for the end of data in each entry as well as at the end of the file proper.

The `getNextEntry()` method is used to reset the input stream ready for reading the data from the next entry.

The input stream classes must also implement a method with the signature:

     public static boolean matches(byte[] signature, int length)

which is used by the `ArchiveStreamFactory` to autodetect the archive type from the first few bytes of a stream.

Constructor Summary
`ArchiveInputStream()`

Method Summary
`boolean` | `canReadEntryData(ArchiveEntry ae)` Whether this stream is able to read the given entry.
`protected void` | `count(int read)` Increments the counter of already read bytes.
`protected void` | `count(long read)` Increments the counter of already read bytes.
`long` | `getBytesRead()` Returns the current number of bytes read from this stream.
`int` | `getCount()` Deprecated. this method may yield wrong results for large archives, use #getBytesRead instead
`abstract ArchiveEntry` | `getNextEntry()` Returns the next Archive Entry in this Stream.
`protected void` | `pushedBackBytes(long pushedBack)` Decrements the counter of already read bytes.
`int` | `read()` Reads a byte of data.

Methods inherited from class java.io.InputStream
`available, close, mark, markSupported, read, read, reset, skip`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### ArchiveInputStream

    public ArchiveInputStream()

Method Detail

### getNextEntry

    public abstract ArchiveEntry getNextEntry()
                                       throws IOException

  Returns the next Archive Entry in this Stream.

  Returns:
    the next entry, or `null` if there are no more entries
  Throws:
    `IOException` - if the next entry could not be read

### read

    public int read()
             throws IOException

  Reads a byte of data. This method will block until enough input is available. Simply calls the `InputStream.read(byte[], int, int)` method. MUST be overridden if the `InputStream.read(byte[], int, int)` method is not overridden; may be overridden otherwise.

  Specified by:
    `read` in class `InputStream`
  Returns:
    the byte read, or -1 if end of input is reached
  Throws:
    `IOException` - if an I/O error has occurred

### count

    protected void count(int read)

  Increments the counter of already read bytes. Doesn't increment if the EOF has been hit (read == -1)

  Parameters:
    `read` - the number of bytes read

### count

    protected void count(long read)

  Increments the counter of already read bytes. Doesn't increment if the EOF has been hit (read == -1)

  Parameters:
    `read` - the number of bytes read
  Since:
    Apache Commons Compress 1.1

### pushedBackBytes

    protected void pushedBackBytes(long pushedBack)

  Decrements the counter of already read bytes.

  Parameters:
    `pushedBack` - the number of bytes pushed back.
  Since:
    Apache Commons Compress 1.1

### getCount

    public int getCount()

  Deprecated. this method may yield wrong results for large archives, use #getBytesRead instead

  Returns the current number of bytes read from this stream.

  Returns:
    the number of read bytes

### getBytesRead

    public long getBytesRead()

  Returns the current number of bytes read from this stream.

  Returns:
    the number of read bytes
  Since:
    Apache Commons Compress 1.1

### canReadEntryData

    public boolean canReadEntryData(ArchiveEntry ae)

  Whether this stream is able to read the given entry.

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

  This implementation always returns true.

  Since:
    Apache Commons Compress 1.1

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2011 The Apache Software Foundation. All Rights Reserved.