Class IsoArchive
- java.lang.Object
-
- com.aspose.zip.IsoArchive
-
- All Implemented Interfaces:
IArchive,AutoCloseable
public final class IsoArchive extends Object implements IArchive, AutoCloseable
Represents an ISO archive (ISO 9660).
-
-
Constructor Summary
Constructors Constructor Description IsoArchive()Initializes a new instance of theIsoArchiveclass and creates an empty ISO archive for adding new files and directories.IsoArchive(InputStream sourceStream)Initializes a new instance of theIsoArchiveclass and composes an entry list that can be extracted from the archive.IsoArchive(InputStream sourceStream, IsoLoadOptions loadOptions)Initializes a new instance of theIsoArchiveclass and composes an entry list that can be extracted from the archive.IsoArchive(String path)Initializes a new instance of theIsoArchiveclass and composes an entry list that can be extracted from the archive.IsoArchive(String path, IsoLoadOptions loadOptions)Initializes a new instance of theIsoArchiveclass and composes an entry list that can be extracted from the archive.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()IsoEntrycreateDirectory(String name)Adds a directory to the ISO image.IsoEntrycreateEntry(String name)Adds a file to the ISO image.IsoEntrycreateEntry(String name, InputStream source)Adds a file to the ISO image.IsoEntrycreateEntry(String name, String filePath)Adds a file to the ISO image.voidextractToDirectory(String destinationDirectory)Extracts all entries to the specified directory.List<IsoEntry>getEntries()Gets entries ofIsoEntrytype constituting the archive.Iterable<IArchiveFileEntry>getFileEntries()Gets entries ofIArchiveFileEntrytype constituting the archive.ArchiveFormatgetFormat()Gets the archive format.voidsave(OutputStream stream)Saves the ISO image to the specified stream.voidsave(OutputStream stream, IsoSaveOptions saveOptions)Saves the ISO image to the specified stream.voidsave(String path)Saves the ISO image to the specified path.voidsave(String path, IsoSaveOptions saveOptions)Saves the ISO image to the specified path.
-
-
-
Constructor Detail
-
IsoArchive
public IsoArchive()
Initializes a new instance of the
The following example shows how to create a new empty ISO archive and add files to it:IsoArchiveclass and creates an empty ISO archive for adding new files and directories.// 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
public IsoArchive(InputStream sourceStream)
Initializes a new instance of the
IsoArchiveclass 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:
sourceStream- the source of the archive- Throws:
com.aspose.ms.System.ArgumentNullException-sourceStreamis null.com.aspose.ms.System.IO.InvalidDataException-sourceStreamis not a valid ISO archive.
-
IsoArchive
public IsoArchive(InputStream sourceStream, IsoLoadOptions loadOptions)
Initializes a new instance of the
IsoArchiveclass 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:
sourceStream- the source of the archiveloadOptions- the options to load archive with- Throws:
com.aspose.ms.System.ArgumentNullException-sourceStreamis null.com.aspose.ms.System.IO.InvalidDataException-sourceStreamis not a valid ISO archive.
-
IsoArchive
public IsoArchive(String path)
Initializes a new instance of the
IsoArchiveclass 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:
path- the path to the archive file- Throws:
com.aspose.ms.System.ArgumentNullException-pathis null.com.aspose.ms.System.SecurityException- The caller does not have the required permission to access.com.aspose.ms.System.ArgumentException- Thepathis empty, contains only white spaces, or contains invalid characters.com.aspose.ms.System.IO.PathTooLongException- The specifiedpath, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.com.aspose.ms.System.NotSupportedException- File atpathcontains a colon (:) in the middle of the string.com.aspose.ms.System.IO.FileNotFoundException- The file is not found.com.aspose.ms.System.IO.DirectoryNotFoundException- The specified path is invalid, such as being on an unmapped drive.com.aspose.ms.System.IO.IOException- The file is already open.com.aspose.ms.System.IO.EndOfStreamException- The file is too short.
-
IsoArchive
public IsoArchive(String path, IsoLoadOptions loadOptions)
Initializes a new instance of the
IsoArchiveclass 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:
path- the path to the archive fileloadOptions- the options to load archive with- Throws:
com.aspose.ms.System.ArgumentNullException-pathis null.com.aspose.ms.System.SecurityException- The caller does not have the required permission to access.com.aspose.ms.System.ArgumentException- Thepathis empty, contains only white spaces, or contains invalid characters.com.aspose.ms.System.IO.PathTooLongException- The specifiedpath, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.com.aspose.ms.System.NotSupportedException- File atpathcontains a colon (:) in the middle of the string.com.aspose.ms.System.IO.FileNotFoundException- The file is not found.com.aspose.ms.System.IO.DirectoryNotFoundException- The specified path is invalid, such as being on an unmapped drive.com.aspose.ms.System.IO.IOException- The file is already open.com.aspose.ms.System.IO.EndOfStreamException- The file is too short.
-
-
Method Detail
-
getEntries
public final List<IsoEntry> getEntries()
Gets entries of
IsoEntrytype constituting the archive.- Returns:
- entries of
IsoEntrytype constituting the iso archive
-
getFileEntries
public final Iterable<IArchiveFileEntry> getFileEntries()
Gets entries of
IArchiveFileEntrytype constituting the archive.- Specified by:
getFileEntriesin interfaceIArchive- Returns:
- entries of
IArchiveFileEntrytype constituting the iso archive
-
getFormat
public ArchiveFormat getFormat()
Gets the archive format.
-
createEntry
public final IsoEntry createEntry(String name, String filePath)
Adds a file to the ISO image.
- Parameters:
name- the path of the file in the ISOfilePath- the path of the file- Returns:
- the ISO entry composed
-
createEntry
public final IsoEntry createEntry(String name, InputStream source)
Adds a file to the ISO image.
- Parameters:
name- the path of the file in the ISOsource- the stream containing the file data- Returns:
- the ISO entry composed
-
createEntry
public final IsoEntry createEntry(String name)
Adds a file to the ISO image.
- Parameters:
name- the path of the file in the ISO- Returns:
- the ISO entry composed
-
createDirectory
public final IsoEntry createDirectory(String name)
Adds a directory to the ISO image.
- Parameters:
name- the path of the directory in the ISO- Returns:
- the ISO entry composed
-
save
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:
path- the path where the ISO image will be saved- Throws:
com.aspose.ms.System.InvalidOperationException- Thrown when the archive is not in editing mode.com.aspose.ms.System.ArgumentNullException- Thrown when thepathis null.com.aspose.ms.System.IO.DirectoryNotFoundException- Thrown when the specified path is invalid, such as being on an unmapped drive.com.aspose.ms.System.IO.IOException- Thrown when the file is already open.com.aspose.ms.System.IO.PathTooLongException- Thrown when the specifiedpathexceeds the system-defined maximum length.
-
save
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:
path- the path where the ISO image will be savedsaveOptions- the options to save ISO archive with- Throws:
com.aspose.ms.System.InvalidOperationException- Thrown when the archive is not in editing mode.com.aspose.ms.System.ArgumentNullException- Thrown when thepathis null.com.aspose.ms.System.IO.DirectoryNotFoundException- Thrown when the specified path is invalid, such as being on an unmapped drive.com.aspose.ms.System.IO.IOException- Thrown when the file is already open.com.aspose.ms.System.IO.PathTooLongException- Thrown when the specifiedpathexceeds the system-defined maximum length.
-
save
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:
stream- the stream where the ISO image will be saved- Throws:
com.aspose.ms.System.InvalidOperationException- Thrown when the archive is not in editing mode.com.aspose.ms.System.ArgumentNullException- Thrown when thestreamis null.com.aspose.ms.System.ArgumentException- Thrown when thestreamis not writable.
-
save
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:
stream- the stream where the ISO image will be savedsaveOptions- the options to save ISO archive with- Throws:
com.aspose.ms.System.InvalidOperationException- Thrown when the archive is not in editing mode.com.aspose.ms.System.ArgumentNullException- Thrown when thestreamis null.com.aspose.ms.System.ArgumentException- Thrown when thestreamis not writable.
-
extractToDirectory
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) { }- Specified by:
extractToDirectoryin interfaceIArchive- Parameters:
destinationDirectory- the directory to extract the entries to- Throws:
com.aspose.ms.System.InvalidOperationException- Thrown when the archive is in editing mode.com.aspose.ms.System.ArgumentNullException- Thrown when thedestinationDirectoryis null.
-
close
public void close()
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceIArchive
-
-