net.sf.sevenzipjbinding
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:
- java.io.Closeable, IOutArchiveBase
- All Known Subinterfaces:
- IOutArchive<T>, IOutCreateArchive7z, IOutCreateArchiveBZip2, IOutCreateArchiveGZip, IOutCreateArchiveTar, IOutCreateArchiveZip
- All Known Implementing Classes:
- OutArchive7zImpl, OutArchiveBZip2Impl, OutArchiveGZipImpl, OutArchiveImpl, OutArchiveTarImpl, OutArchiveZipImpl
public interface IOutCreateArchive<T extends IOutItemBase>
- extends IOutArchiveBase, java.io.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.
The 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<
IOutItemCallback>
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 corresponding archive format specific interfaces. Those interfaces contain
all supported configuration methods for selected archive format. No cast or instanceof
check are 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
Methods inherited from interface java.io.Closeable |
close |
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 archiveoutCreateCallback
- callback object to exchange information about the archive create operation.
- Throws:
SevenZipException
- 7-Zip or 7-Zip-JBinding error occur. Use SevenZipException.printStackTraceExtended()
to get
stack traces of this SevenZipException and of the all thrown 'cause by' exceptions.
getArchiveFormat
ArchiveFormat getArchiveFormat()
- Return archive format used with this instance of
IOutStream
- Returns:
- archive format used with this instance of
IOutStream