Class Expander


  • public class Expander
    extends Object
    Provides a high level API for expanding archives.
    Since:
    1.17
    • Method Detail

      • expand

        public void expand​(File archive,
                           File targetDirectory)
                    throws IOException,
                           ArchiveException
        Expands archive into targetDirectory.

        Tries to auto-detect the archive's format.

        Parameters:
        archive - the file to expand
        targetDirectory - the directory to write to
        Throws:
        IOException - if an I/O error occurs
        ArchiveException - if the archive cannot be read for other reasons
      • expand

        public void expand​(InputStream archive,
                           File targetDirectory,
                           CloseableConsumer closeableConsumer)
                    throws IOException,
                           ArchiveException
        Expands archive into targetDirectory.

        Tries to auto-detect the archive's format.

        This method creates a wrapper around the archive stream and the caller of this method is responsible for closing it - probably at the same time as closing the stream itself. The caller is informed about the wrapper object via the closeableConsumer callback as soon as it is no longer needed by this class.

        Parameters:
        archive - the file to expand
        targetDirectory - the directory to write to
        closeableConsumer - is informed about the stream wrapped around the passed in stream
        Throws:
        IOException - if an I/O error occurs
        ArchiveException - if the archive cannot be read for other reasons
        Since:
        1.19
      • expand

        public void expand​(String format,
                           InputStream archive,
                           File targetDirectory,
                           CloseableConsumer closeableConsumer)
                    throws IOException,
                           ArchiveException
        Expands archive into targetDirectory.

        This method creates a wrapper around the archive stream and the caller of this method is responsible for closing it - probably at the same time as closing the stream itself. The caller is informed about the wrapper object via the closeableConsumer callback as soon as it is no longer needed by this class.

        Parameters:
        archive - the file to expand
        targetDirectory - the directory to write to
        format - the archive format. This uses the same format as accepted by ArchiveStreamFactory.
        closeableConsumer - is informed about the stream wrapped around the passed in stream
        Throws:
        IOException - if an I/O error occurs
        ArchiveException - if the archive cannot be read for other reasons
        Since:
        1.19
      • expand

        public void expand​(String format,
                           SeekableByteChannel archive,
                           File targetDirectory,
                           CloseableConsumer closeableConsumer)
                    throws IOException,
                           ArchiveException
        Expands archive into targetDirectory.

        This method creates a wrapper around the archive channel and the caller of this method is responsible for closing it - probably at the same time as closing the channel itself. The caller is informed about the wrapper object via the closeableConsumer callback as soon as it is no longer needed by this class.

        Parameters:
        archive - the file to expand
        targetDirectory - the directory to write to
        format - the archive format. This uses the same format as accepted by ArchiveStreamFactory.
        closeableConsumer - is informed about the stream wrapped around the passed in channel
        Throws:
        IOException - if an I/O error occurs
        ArchiveException - if the archive cannot be read for other reasons
        Since:
        1.19