CabArchive
Inheritance: java.lang.Object
All Implemented Interfaces: com.aspose.zip.IArchive, java.lang.AutoCloseable
public class CabArchive implements IArchive, AutoCloseable
This class represents cab archive file.
Constructors
Constructor | Description |
---|---|
CabArchive(InputStream sourceStream) | Initializes a new instance of the CabArchive class and composes entries list can be extracted from the archive. |
CabArchive(String path) | Initializes a new instance of the CabArchive class and composes entries list can be extracted from the archive. |
Methods
Method | Description |
---|---|
close() | {@inheritDoc} |
extractToDirectory(String destinationDirectory) | Extracts all the files in the archive to the directory provided. |
getEntries() | Gets entries of CabEntry type constituting the archive. |
getFileEntries() | Gets entries of IArchiveFileEntry type constituting the cab archive. |
CabArchive(InputStream sourceStream)
public CabArchive(InputStream sourceStream)
Initializes a new instance of the CabArchive class and composes entries list can be extracted from the archive.
The following example shows how to extract all of the entries to a directory.
try (CabArchive archive = new CabArchive(new FileInputStream("archive.cab"))) {
archive.extractToDirectory("C:\\extracted");
} catch (IOException ex) {
}
This constructor does not unpack any entry. See CabEntry.open() method for unpacking.
Parameters:
Parameter | Type | Description |
---|---|---|
sourceStream | java.io.InputStream | the source of the archive |
CabArchive(String path)
public CabArchive(String path)
Initializes a new instance of the CabArchive class and composes entries list can be extracted from the archive.
The following example shows how to extract all of the entries to a directory.
try (CabArchive archive = new CabArchive("archive.cab")) {
archive.extractToDirectory("C:\\extracted");
} catch (IOException ex) {
}
This constructor does not unpack any entry. See CabEntry.open() method for unpacking.
Parameters:
Parameter | Type | Description |
---|---|---|
path | java.lang.String | the path to the archive file |
close()
public void close()
extractToDirectory(String destinationDirectory)
public final void extractToDirectory(String destinationDirectory)
Extracts all the files in the archive to the directory provided.
try (CabArchive archive = new CabArchive("archive.cab")) {
archive.extractToDirectory("C:\\extracted");
} catch (IOException ex) {
}
Parameters:
Parameter | Type | Description |
---|---|---|
destinationDirectory | java.lang.String | the path to the directory to place the extracted files in. |
If the directory does not exist, it will be created |
getEntries()
public final List<CabEntry> getEntries()
Gets entries of CabEntry type constituting the archive.
Returns: java.util.List<com.aspose.zip.CabEntry> - entries of CabEntry type constituting the archive
getFileEntries()
public final Iterable<IArchiveFileEntry> getFileEntries()
Gets entries of IArchiveFileEntry type constituting the cab archive.
Returns: java.lang.Iterable<com.aspose.zip.IArchiveFileEntry> - entries of IArchiveFileEntry type constituting the cab archive