Class DumpArchiveInputStream

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

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(). There doesn't seem to exist a hint on the encoding of string values in any piece documentation. Given the main purpose of dump/restore is backing up a system it seems very likely the format uses the current default encoding of the system.
This class is not thread-safe
  • Field Details

    • raw

      protected org.apache.commons.compress.archivers.dump.TapeInputStream raw
  • Constructor Details

  • Method Details

    • 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.
      Parameters:
      buffer - data to match
      length - length of data
      Returns:
      whether the buffer seems to contain dump data
    • close

      public void close() throws IOException
      Closes the stream for this entry.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class InputStream
      Throws:
      IOException
    • 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
    • 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
    • getNextDumpEntry

      Read the next entry.
      Returns:
      the next entry
      Throws:
      IOException - on error
    • getNextEntry

      Description copied from class: ArchiveInputStream
      Returns the next Archive Entry in this Stream.
      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
    • getSummary

      Return the archive summary information.
      Returns:
      the summary
    • 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