Class SevenZOutputFile

    • Constructor Detail

      • SevenZOutputFile

        public SevenZOutputFile​(File fileName)
                         throws IOException
        Opens file to write a 7z archive to.
        Parameters:
        fileName - the file to write to
        Throws:
        IOException - if opening the file fails
    • Method Detail

      • createArchiveEntry

        public SevenZArchiveEntry createArchiveEntry​(File inputFile,
                                                     String entryName)
                                              throws IOException
        Create an archive entry using the inputFile and entryName provided.
        Parameters:
        inputFile - file to create an entry from
        entryName - the name to use
        Returns:
        the ArchiveEntry set up with details from the file
        Throws:
        IOException - on error
      • createArchiveEntry

        public SevenZArchiveEntry createArchiveEntry​(Path inputPath,
                                                     String entryName,
                                                     LinkOption... options)
                                              throws IOException
        Create an archive entry using the inputPath and entryName provided.
        Parameters:
        inputPath - path to create an entry from
        entryName - the name to use
        options - options indicating how symbolic links are handled.
        Returns:
        the ArchiveEntry set up with details from the file
        Throws:
        IOException - on error
        Since:
        1.21
      • putArchiveEntry

        public void putArchiveEntry​(ArchiveEntry archiveEntry)
                             throws IOException
        Records an archive entry to add. The caller must then write the content to the archive and call closeArchiveEntry() to complete the process.
        Parameters:
        archiveEntry - describes the entry
        Throws:
        IOException - on error
      • closeArchiveEntry

        public void closeArchiveEntry()
                               throws IOException
        Closes the archive entry.
        Throws:
        IOException - on error
      • write

        public void write​(int b)
                   throws IOException
        Writes a byte to the current archive entry.
        Parameters:
        b - The byte to be written.
        Throws:
        IOException - on error
      • write

        public void write​(byte[] b)
                   throws IOException
        Writes a byte array to the current archive entry.
        Parameters:
        b - The byte array to be written.
        Throws:
        IOException - on error
      • write

        public void write​(byte[] b,
                          int off,
                          int len)
                   throws IOException
        Writes part of a byte array to the current archive entry.
        Parameters:
        b - The byte array to be written.
        off - offset into the array to start writing from
        len - number of bytes to write
        Throws:
        IOException - on error
      • write

        public void write​(InputStream inputStream)
                   throws IOException
        Writes all of the given input stream to the current archive entry.
        Parameters:
        inputStream - the data source.
        Throws:
        IOException - if an I/O error occurs.
        Since:
        1.21
      • write

        public void write​(Path path,
                          OpenOption... options)
                   throws IOException
        Writes all of the given input stream to the current archive entry.
        Parameters:
        path - the data source.
        options - options specifying how the file is opened.
        Throws:
        IOException - if an I/O error occurs.
        Since:
        1.21
      • finish

        public void finish()
                    throws IOException
        Finishes the addition of entries to this archive, without closing it.
        Throws:
        IOException - if archive is already closed.