org.apache.commons.compress.archivers.dump
Class DumpArchiveInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by org.apache.commons.compress.archivers.ArchiveInputStream
          extended by org.apache.commons.compress.archivers.dump.DumpArchiveInputStream
All Implemented Interfaces:
Closeable

public class DumpArchiveInputStream
extends ArchiveInputStream

The DumpArchiveInputStream reads a UNIX dump archive as an InputStream. Methods are provided to position at each successive entry in the archive, and the read each entry as a normal input stream using read().


Field Summary
protected  org.apache.commons.compress.archivers.dump.TapeInputStream raw
           
 
Constructor Summary
DumpArchiveInputStream(InputStream is)
          Constructor.
 
Method Summary
 void close()
          Closes the stream for this entry.
 long getBytesRead()
          Returns the current number of bytes read from this stream.
 int getCount()
          Deprecated. 
 DumpArchiveEntry getNextDumpEntry()
          Read the next entry.
 DumpArchiveEntry getNextEntry()
          Read the next entry.
 DumpArchiveSummary getSummary()
          Return the archive summary information.
static boolean matches(byte[] buffer, int length)
          Look at the first few bytes of the file to decide if it's a dump archive.
 int read(byte[] buf, int off, int len)
          Reads bytes from the current dump archive entry.
 
Methods inherited from class org.apache.commons.compress.archivers.ArchiveInputStream
canReadEntryData, count, count, pushedBackBytes, read
 
Methods inherited from class java.io.InputStream
available, mark, markSupported, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

raw

protected org.apache.commons.compress.archivers.dump.TapeInputStream raw
Constructor Detail

DumpArchiveInputStream

public DumpArchiveInputStream(InputStream is)
                       throws ArchiveException
Constructor.

Parameters:
is -
Throws:
ArchiveException
Method Detail

getCount

@Deprecated
public int getCount()
Deprecated. 

Description copied from class: ArchiveInputStream
Returns the current number of bytes read from this stream.

Overrides:
getCount in class ArchiveInputStream
Returns:
the number of read bytes

getBytesRead

public long getBytesRead()
Description copied from class: ArchiveInputStream
Returns the current number of bytes read from this stream.

Overrides:
getBytesRead in class ArchiveInputStream
Returns:
the number of read bytes

getSummary

public DumpArchiveSummary getSummary()
Return the archive summary information.


getNextDumpEntry

public DumpArchiveEntry getNextDumpEntry()
                                  throws IOException
Read the next entry.

Throws:
IOException

getNextEntry

public DumpArchiveEntry getNextEntry()
                              throws IOException
Read the next entry.

Specified by:
getNextEntry in class ArchiveInputStream
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(byte[] buf,
                int off,
                int len)
         throws IOException
Reads bytes from the current dump archive entry. This method is aware of the boundaries of the current entry in the archive and will deal with them as if they were this stream's start and EOF.

Overrides:
read in class InputStream
Parameters:
buf - The buffer into which to place bytes read.
off - The offset at which to place bytes read.
len - The number of bytes to read.
Returns:
The number of bytes read, or -1 at EOF.
Throws:
IOException - on error

close

public void close()
           throws IOException
Closes the stream for this entry.

Specified by:
close in interface Closeable
Overrides:
close in class InputStream
Throws:
IOException

matches

public static boolean matches(byte[] buffer,
                              int length)
Look at the first few bytes of the file to decide if it's a dump archive. With 32 bytes we can look at the magic value, with a full 1k we can verify the checksum.



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