Class Archiver


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

      • create

        public void create​(String format,
                           File target,
                           File directory)
                    throws IOException,
                           ArchiveException
        Creates an archive target using the format format by recursively including all files and directories in directory.
        Parameters:
        format - the archive format. This uses the same format as accepted by ArchiveStreamFactory.
        target - the file to write the new archive to.
        directory - the directory that contains the files to archive.
        Throws:
        IOException - if an I/O error occurs
        ArchiveException - if the archive cannot be created for other reasons
      • create

        public void create​(String format,
                           OutputStream target,
                           File directory,
                           CloseableConsumer closeableConsumer)
                    throws IOException,
                           ArchiveException
        Creates an archive target using the format format by recursively including all files and directories in directory.

        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:
        format - the archive format. This uses the same format as accepted by ArchiveStreamFactory.
        target - the stream to write the new archive to.
        directory - the directory that contains the files to archive.
        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 created for other reasons
        Since:
        1.19
      • create

        public void create​(String format,
                           SeekableByteChannel target,
                           File directory,
                           CloseableConsumer closeableConsumer)
                    throws IOException,
                           ArchiveException
        Creates an archive target using the format format by recursively including all files and directories in directory.

        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:
        format - the archive format. This uses the same format as accepted by ArchiveStreamFactory.
        target - the channel to write the new archive to.
        directory - the directory that contains the files to archive.
        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 created for other reasons
        Since:
        1.19
      • create

        public void create​(ArchiveOutputStream target,
                           File directory)
                    throws IOException,
                           ArchiveException
        Creates an archive target by recursively including all files and directories in directory.
        Parameters:
        target - the stream to write the new archive to.
        directory - the directory that contains the files to archive.
        Throws:
        IOException - if an I/O error occurs
        ArchiveException - if the archive cannot be created for other reasons
      • create

        public void create​(SevenZOutputFile target,
                           File directory)
                    throws IOException
        Creates an archive target by recursively including all files and directories in directory.
        Parameters:
        target - the file to write the new archive to.
        directory - the directory that contains the files to archive.
        Throws:
        IOException - if an I/O error occurs