IsoArchive
Inheritance: java.lang.Object
All Implemented Interfaces: com.aspose.zip.IArchive, java.lang.AutoCloseable
public final class IsoArchive implements IArchive, AutoCloseable
Represents an ISO archive (ISO 9660).
Constructors
| Constructor | Description |
|---|---|
| IsoArchive() | Initializes a new instance of the IsoArchive class and creates an empty ISO archive for adding new files and directories. |
| IsoArchive(InputStream sourceStream) | Initializes a new instance of the IsoArchive class and composes an entry list that can be extracted from the archive. |
| IsoArchive(InputStream sourceStream, IsoLoadOptions loadOptions) | Initializes a new instance of the IsoArchive class and composes an entry list that can be extracted from the archive. |
| IsoArchive(String path) | Initializes a new instance of the IsoArchive class and composes an entry list that can be extracted from the archive. |
| IsoArchive(String path, IsoLoadOptions loadOptions) | Initializes a new instance of the IsoArchive class and composes an entry list that can be extracted from the archive. |
Methods
| Method | Description |
|---|---|
| close() | {@inheritDoc} |
| createDirectory(String name) | Adds a directory to the ISO image. |
| createEntry(String name) | Adds a file to the ISO image. |
| createEntry(String name, InputStream source) | Adds a file to the ISO image. |
| createEntry(String name, String filePath) | Adds a file to the ISO image. |
| extractToDirectory(String destinationDirectory) | Extracts all entries to the specified directory. |
| getEntries() | Gets entries of IsoEntry type constituting the archive. |
| getFileEntries() | Gets entries of IArchiveFileEntry type constituting the archive. |
| getFormat() | Gets the archive format. |
| save(OutputStream stream) | Saves the ISO image to the specified stream. |
| save(OutputStream stream, IsoSaveOptions saveOptions) | Saves the ISO image to the specified stream. |
| save(String path) | Saves the ISO image to the specified path. |
| save(String path, IsoSaveOptions saveOptions) | Saves the ISO image to the specified path. |
IsoArchive()
public IsoArchive()
Initializes a new instance of the IsoArchive class and creates an empty ISO archive for adding new files and directories.
The following example shows how to create a new empty ISO archive and add files to it:
// Create a new empty ISO archive
try (IsoArchive isoArchive = new IsoArchive()) {
// Add files to the ISO archive
isoArchive.createEntry("example_file.txt", "path_to_file.txt");
// Save the ISO archive to a file
isoArchive.save("new_archive.iso");
}
### IsoArchive(InputStream sourceStream) {#IsoArchive-java.io.InputStream-}
public IsoArchive(InputStream sourceStream)
Initializes a new instance of the [IsoArchive](../../com.aspose.zip/isoarchive) class and composes an entry list that can be extracted from the archive.
The following example shows how to extract all the entries to a directory.
try (IsoArchive archive = new IsoArchive(new FileInputStream("archive.iso"))) {
archive.extractToDirectory("C:\\extracted");
} catch (IOException ex) {
}
```
This constructor does not unpack any entry.
**Parameters:**
| Parameter | Type | Description |
| --- | --- | --- |
| sourceStream | java.io.InputStream | the source of the archive |
### IsoArchive(InputStream sourceStream, IsoLoadOptions loadOptions) {#IsoArchive-java.io.InputStream-com.aspose.zip.IsoLoadOptions-}
```
public IsoArchive(InputStream sourceStream, IsoLoadOptions loadOptions)
```
Initializes a new instance of the [IsoArchive](../../com.aspose.zip/isoarchive) class and composes an entry list that can be extracted from the archive.
The following example shows how to extract all the entries to a directory.
```
try (IsoArchive archive = new IsoArchive(new FileInputStream("archive.iso"))) {
archive.extractToDirectory("C:\\extracted");
} catch (IOException ex) {
}
This constructor does not unpack any entry.
**Parameters:**
| Parameter | Type | Description |
| --- | --- | --- |
| sourceStream | java.io.InputStream | the source of the archive |
| loadOptions | [IsoLoadOptions](../../com.aspose.zip/isoloadoptions) | the options to load archive with |
### IsoArchive(String path) {#IsoArchive-java.lang.String-}
public IsoArchive(String path)
Initializes a new instance of the [IsoArchive](../../com.aspose.zip/isoarchive) class and composes an entry list that can be extracted from the archive.
The following example shows how to extract all the entries to a directory.
try (IsoArchive archive = new IsoArchive("archive.iso")) {
archive.extractToDirectory("C:\\extracted");
}
```
This constructor does not unpack any entry.
**Parameters:**
| Parameter | Type | Description |
| --- | --- | --- |
| path | java.lang.String | the path to the archive file |
### IsoArchive(String path, IsoLoadOptions loadOptions) {#IsoArchive-java.lang.String-com.aspose.zip.IsoLoadOptions-}
```
public IsoArchive(String path, IsoLoadOptions loadOptions)
```
Initializes a new instance of the [IsoArchive](../../com.aspose.zip/isoarchive) class and composes an entry list that can be extracted from the archive.
The following example shows how to extract all the entries to a directory.
```
try (IsoArchive archive = new IsoArchive("archive.iso")) {
archive.extractToDirectory("C:\\extracted");
}
This constructor does not unpack any entry.
**Parameters:**
| Parameter | Type | Description |
| --- | --- | --- |
| path | java.lang.String | the path to the archive file |
| loadOptions | [IsoLoadOptions](../../com.aspose.zip/isoloadoptions) | the options to load archive with |
### close() {#close--}
public void close()
### createDirectory(String name) {#createDirectory-java.lang.String-}
public final IsoEntry createDirectory(String name)
Adds a directory to the ISO image.
**Parameters:**
| Parameter | Type | Description |
| --- | --- | --- |
| name | java.lang.String | the path of the directory in the ISO |
**Returns:**
[IsoEntry](../../com.aspose.zip/isoentry) - the ISO entry composed
### createEntry(String name) {#createEntry-java.lang.String-}
public final IsoEntry createEntry(String name)
Adds a file to the ISO image.
**Parameters:**
| Parameter | Type | Description |
| --- | --- | --- |
| name | java.lang.String | the path of the file in the ISO |
**Returns:**
[IsoEntry](../../com.aspose.zip/isoentry) - the ISO entry composed
### createEntry(String name, InputStream source) {#createEntry-java.lang.String-java.io.InputStream-}
public final IsoEntry createEntry(String name, InputStream source)
Adds a file to the ISO image.
**Parameters:**
| Parameter | Type | Description |
| --- | --- | --- |
| name | java.lang.String | the path of the file in the ISO |
| source | java.io.InputStream | the stream containing the file data |
**Returns:**
[IsoEntry](../../com.aspose.zip/isoentry) - the ISO entry composed
### createEntry(String name, String filePath) {#createEntry-java.lang.String-java.lang.String-}
public final IsoEntry createEntry(String name, String filePath)
Adds a file to the ISO image.
**Parameters:**
| Parameter | Type | Description |
| --- | --- | --- |
| name | java.lang.String | the path of the file in the ISO |
| filePath | java.lang.String | the path of the file |
**Returns:**
[IsoEntry](../../com.aspose.zip/isoentry) - the ISO entry composed
### extractToDirectory(String destinationDirectory) {#extractToDirectory-java.lang.String-}
public final void extractToDirectory(String destinationDirectory)
Extracts all entries to the specified directory.
The following example shows how to extract all entries to a directory:
try (IsoArchive archive = new IsoArchive(new FileInputStream("archive.iso"))) {
archive.extractToDirectory("C:\\extracted");
} catch (IOException ex) {
}
```
**Parameters:**
| Parameter | Type | Description |
| --- | --- | --- |
| destinationDirectory | java.lang.String | the directory to extract the entries to |
### getEntries() {#getEntries--}
```
public final List<IsoEntry> getEntries()
```
Gets entries of [IsoEntry](../../com.aspose.zip/isoentry) type constituting the archive.
**Returns:**
java.util.List<com.aspose.zip.IsoEntry> - entries of [IsoEntry](../../com.aspose.zip/isoentry) type constituting the iso archive
### getFileEntries() {#getFileEntries--}
```
public final Iterable<IArchiveFileEntry> getFileEntries()
```
Gets entries of [IArchiveFileEntry](../../com.aspose.zip/iarchivefileentry) type constituting the archive.
**Returns:**
java.lang.Iterable<com.aspose.zip.IArchiveFileEntry> - entries of [IArchiveFileEntry](../../com.aspose.zip/iarchivefileentry) type constituting the iso archive
### getFormat() {#getFormat--}
```
public ArchiveFormat getFormat()
```
Gets the archive format.
**Returns:**
[ArchiveFormat](../../com.aspose.zip/archiveformat) - the archive format
### save(OutputStream stream) {#save-java.io.OutputStream-}
```
public final void save(OutputStream stream)
```
Saves the ISO image to the specified stream.
The following example shows how to save an ISO archive to a memory stream:
```
ByteArrayOutputStream memoryStream = new ByteArrayOutputStream();
// Create a new empty ISO archive
try (IsoArchive isoArchive = new IsoArchive()) {
// Add files to the ISO archive
isoArchive.createEntry("example_file.txt", "path_to_file.txt");
// Save the ISO archive to a memory stream
isoArchive.save(memoryStream);
}
**Parameters:**
| Parameter | Type | Description |
| --- | --- | --- |
| stream | java.io.OutputStream | the stream where the ISO image will be saved |
### save(OutputStream stream, IsoSaveOptions saveOptions) {#save-java.io.OutputStream-com.aspose.zip.IsoSaveOptions-}
public final void save(OutputStream stream, IsoSaveOptions saveOptions)
Saves the ISO image to the specified stream.
The following example shows how to save an ISO archive to a memory stream:
ByteArrayOutputStream memoryStream = new ByteArrayOutputStream();
// Create a new empty ISO archive
try (IsoArchive isoArchive = new IsoArchive()) {
// Add files to the ISO archive
isoArchive.createEntry("example_file.txt", "path_to_file.txt");
// Save the ISO archive to a memory stream
isoArchive.save(memoryStream);
}
```
**Parameters:**
| Parameter | Type | Description |
| --- | --- | --- |
| stream | java.io.OutputStream | the stream where the ISO image will be saved |
| saveOptions | [IsoSaveOptions](../../com.aspose.zip/isosaveoptions) | the options to save ISO archive with |
### save(String path) {#save-java.lang.String-}
```
public final void save(String path)
```
Saves the ISO image to the specified path.
The following example shows how to save an ISO archive to a file:
```
// Create a new empty ISO archive
try (IsoArchive isoArchive = new IsoArchive()) {
// Add files to the ISO archive
isoArchive.createEntry("example_file.txt", "path_to_file.txt");
// Save the ISO archive to a file
isoArchive.save("new_archive.iso");
}
**Parameters:**
| Parameter | Type | Description |
| --- | --- | --- |
| path | java.lang.String | the path where the ISO image will be saved |
### save(String path, IsoSaveOptions saveOptions) {#save-java.lang.String-com.aspose.zip.IsoSaveOptions-}
public final void save(String path, IsoSaveOptions saveOptions)
Saves the ISO image to the specified path.
The following example shows how to save an ISO archive to a file:
// Create a new empty ISO archive
try (IsoArchive isoArchive = new IsoArchive()) {
// Add files to the ISO archive
isoArchive.createEntry("example_file.txt", "path_to_file.txt");
// Save the ISO archive to a file
isoArchive.save("new_archive.iso");
}
```
**Parameters:**
| Parameter | Type | Description |
| --- | --- | --- |
| path | java.lang.String | the path where the ISO image will be saved |
| saveOptions | [IsoSaveOptions](../../com.aspose.zip/isosaveoptions) | the options to save ISO archive with |