CabEntry
Inheritance: java.lang.Object
All Implemented Interfaces: com.aspose.zip.IArchiveFileEntry
public final class CabEntry implements IArchiveFileEntry
Represents a single file within cab archive.
Methods
| Method | Description |
|---|---|
| extract(OutputStream destination) | Extracts the entry to the stream provided. |
| extract(String path) | Extracts the entry to the filesystem by the path provided. |
| getLength() | Gets the length of the entry in bytes. |
| getModificationTime() | Gets last modified date and time. |
| getName() | Gets the name of the entry within the archive. |
| open() | Opens the entry for extraction and provides a stream with entry content. |
| toString() | Returns string representation of the instance of the CabEntry class. |
extract(OutputStream destination)
public final void extract(OutputStream destination)
Extracts the entry to the stream provided.
Extract an entry of CAB archive.
try (CabArchive archive = new CabArchive("archive.cab")) {
archive.getEntries().get(0).extract(httpResponseStream);
}
**Parameters:**
| Parameter | Type | Description |
| --- | --- | --- |
| destination | java.io.OutputStream | destination stream. Must be writable |
### extract(String path) {#extract-java.lang.String-}
public final File extract(String path)
Extracts the entry to the filesystem by the path provided.
try (CabArchive archive = new CabArchive("archive.cab")) {
archive.getEntries().get(0).extract("data.bin");
}
```
**Parameters:**
| Parameter | Type | Description |
| --- | --- | --- |
| path | java.lang.String | the path to destination file. If the file already exists, it will be overwritten |
**Returns:**
java.io.File - the file info of a composed file
### getLength() {#getLength--}
```
public final Long getLength()
```
Gets the length of the entry in bytes.
**Returns:**
java.lang.Long - the length of the entry in bytes
### getModificationTime() {#getModificationTime--}
```
public final Date getModificationTime()
```
Gets last modified date and time.
**Returns:**
java.util.Date - last modified date and time.
### getName() {#getName--}
```
public final String getName()
```
Gets the name of the entry within the archive.
**Returns:**
java.lang.String - the name of the entry within the archive
### open() {#open--}
```
public final InputStream open()
```
Opens the entry for extraction and provides a stream with entry content.
Usage:
```
CabArchive archive = new CabArchive("archive.cab");
CabEntry entry = archive.getEntries().get(0);
try (FileOutputStream fileStream = new FileOutputStream("data.bin")) {
try (InputStream decompressed = entry.open()) {
byte[] buffer = new byte[8192];
int bytesRead;
while (0 < (bytesRead = decompressed.read(buffer, 0, buffer.length))) {
fileStream.write(buffer, 0, bytesRead);
}
}
} catch (IOException ex) {
}
Read from the stream to get the original content of a file. See examples section.
**Returns:**
java.io.InputStream - the stream that represents the contents of the entry
### toString() {#toString--}
public String toString()
Returns string representation of the instance of the [CabEntry](../../com.aspose.zip/cabentry) class.
**Returns:**
java.lang.String - string representation of this object