Interface IOutCreateArchive<T extends IOutItemBase>

Type Parameters:
T - the type of the corresponding archive item data class (out item), like IOutItem7z or IOutItemZip. Use IOutItemAllFormats interface to support all available archive formats.
All Superinterfaces:
AutoCloseable, Closeable, IOutArchiveBase
All Known Subinterfaces:
IOutArchive<T>, IOutCreateArchive7z, IOutCreateArchiveBZip2, IOutCreateArchiveGZip, IOutCreateArchiveTar, IOutCreateArchiveXz, IOutCreateArchiveZip
All Known Implementing Classes:
OutArchive7zImpl, OutArchiveBZip2Impl, OutArchiveGZipImpl, OutArchiveImpl, OutArchiveTarImpl, OutArchiveXzImpl, OutArchiveZipImpl

public interface IOutCreateArchive<T extends IOutItemBase> extends IOutArchiveBase, Closeable
The central interface to create new archives. To update an existing archive open it first and then use IInArchive.getConnectedOutArchive() to get an instance of the IOutUpdateArchive interface.

There are two ways of getting an implementation of this interface:
  • use SevenZip.openOutArchive(ArchiveFormat)
    The method returns an instance of the IOutCreateArchive<IOutItemAllFormats> interface allowing creation of a new archive of any supported archive format. To get all currently supported formats see the 'compression' column of the ArchiveFormat-JavaDoc. The user can check whether the current archive format supports a particular configuration method by making an instanceof check, like this:
      IOutCreateArchive<IOutItemAllFormats> outArchive = SevenZip.openOutArchive(myArchiveFormat);
      if (outArchive instanceof IOutFeatureSetLevel) {
          ((IOutFeatureSetLevel)outArchive).setLevel(myLevel);
      }
    
      ...
    
      outArchive.close();
     
  • use one of the SevenZip.openOutArchiveXxx
    Those methods provide implementations of the corresponding archive-format-specific interfaces. Those interfaces contain all supported configuration methods for the selected archive format. No cast or instanceof check is needed in this case.
    For example, the method SevenZip.openOutArchive7z() returns an implementation of the IOutCreateArchive7z interface with all configuration methods, supported by the 7z format, like IOutFeatureSetLevel.setLevel(int).
     IOutCreateArchive7z outArchive7z = SevenZip.openOutArchive7z();
     outArchive7z.setLevel(myLevel);
    
     ...
    
     outArchive7z.close();
     
NOTE: Each instance should be closed using Closeable.close() method.
Since:
9.20-2.00
Author:
Boris Brodski
  • Method Details

    • createArchive

      void createArchive(ISequentialOutStream outStream, int numberOfItems, IOutCreateCallback<? extends T> outCreateCallback) throws SevenZipException
      Create new archive. To update an existing archive open it first and then use IInArchive.getConnectedOutArchive() to get an instance of the IOutUpdateArchive interface.

      The outCreateCallback is designed to provide necessary information about new archive items and to receive information about the progress of the operation.

      Note: some archive formats (like Zip) require an implementation of the IOutStream interface (instead of the ISequentialOutStream) to be passed.
      Parameters:
      outStream - output stream to receive the new archive. An implementation of the IOutStream interface is required for some archive formats.
      numberOfItems - number of items in the new archive
      outCreateCallback - callback object to exchange information about the archive create operation.
      Throws:
      SevenZipException - 7-Zip or 7-Zip-JBinding error occurs. Use SevenZipException.printStackTraceExtended() to get stack traces of this SevenZipException and of all thrown 'caused by' exceptions.
    • getArchiveFormat

      ArchiveFormat getArchiveFormat()
      Return the archive format of this out-archive instance
      Returns:
      the archive format of this out-archive instance