IsoArchive
Inheritance: java.lang.Object
All Implemented Interfaces: com.aspose.zip.ICompressionArchive, com.aspose.zip.IArchive, java.lang.AutoCloseable
public final class IsoArchive implements ICompressionArchive, 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 entries list that can be extracted from the archive. |
IsoArchive(String path) | Initializes a new instance of the IsoArchive class and composes entries 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. |
save(OutputStream stream) | Saves the ISO image to the specified stream. |
save(String path) | 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)
public IsoArchive(InputStream sourceStream)
Initializes a new instance of the IsoArchive class and composes entries list that can be extracted from the archive.
The following example shows how to extract all of 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(String path)
public IsoArchive(String path)
Initializes a new instance of the IsoArchive class and composes entries list that can be extracted from the archive.
The following example shows how to extract all of 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 |
close()
public void close()
createDirectory(String name)
public final void 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 |
createEntry(String name)
public final void 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 |
createEntry(String name, InputStream source)
public final void 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 |
createEntry(String name, String filePath)
public final void 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 |
extractToDirectory(String destinationDirectory)
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()
public final List<IsoEntry> getEntries()
Gets entries of IsoEntry type constituting the archive.
Returns: java.util.List<com.aspose.zip.IsoEntry> - entries of IsoEntry type constituting the iso archive
getFileEntries()
public final Iterable<IArchiveFileEntry> getFileEntries()
Gets entries of IArchiveFileEntry type constituting the archive.
Returns: java.lang.Iterable<com.aspose.zip.IArchiveFileEntry> - entries of IArchiveFileEntry type constituting the iso archive
save(OutputStream stream)
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(String path)
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 |