Class DumpArchiveInputStream

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

    public class DumpArchiveInputStream
    extends ArchiveInputStream<DumpArchiveEntry>
    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.

    Since:
    1.3
    • Constructor Detail

      • DumpArchiveInputStream

        public DumpArchiveInputStream​(java.io.InputStream is)
                               throws ArchiveException
        Constructor using the platform's default encoding for file names.
        Parameters:
        is - stream to read from
        Throws:
        ArchiveException - on error
      • DumpArchiveInputStream

        public DumpArchiveInputStream​(java.io.InputStream is,
                                      java.lang.String encoding)
                               throws ArchiveException
        Constructs a new instance.
        Parameters:
        is - stream to read from
        encoding - the encoding to use for file names, use null for the platform's default encoding
        Throws:
        ArchiveException - on error
        Since:
        1.6
    • Method Detail

      • 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 java.io.IOException
        Closes the stream for this entry.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class java.io.FilterInputStream
        Throws:
        java.io.IOException
      • getNextDumpEntry

        @Deprecated
        public DumpArchiveEntry getNextDumpEntry()
                                          throws java.io.IOException
        Deprecated.
        Reads the next entry.
        Returns:
        the next entry
        Throws:
        java.io.IOException - on error
      • getSummary

        public DumpArchiveSummary getSummary()
        Gets the archive summary information.
        Returns:
        the summary
      • read

        public int read​(byte[] buf,
                        int off,
                        int len)
                 throws java.io.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 java.io.FilterInputStream
        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:
        java.io.IOException - on error