Class IsoArchive

    • Constructor Detail

      • 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

        public IsoArchive​(InputStream sourceStream)

        Initializes a new instance of the 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:
        sourceStream - the source of the archive
        Throws:
        com.aspose.ms.System.ArgumentNullException - sourceStream is null.
        com.aspose.ms.System.IO.InvalidDataException - sourceStream is not a valid ISO archive.
      • IsoArchive

        public 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.

        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
        loadOptions - the options to load archive with
        Throws:
        com.aspose.ms.System.ArgumentNullException - sourceStream is null.
        com.aspose.ms.System.IO.InvalidDataException - sourceStream is not a valid ISO archive.
      • IsoArchive

        public IsoArchive​(String path)

        Initializes a new instance of the 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:
        path - the path to the archive file
        Throws:
        com.aspose.ms.System.ArgumentNullException - path is null.
        com.aspose.ms.System.SecurityException - The caller does not have the required permission to access.
        com.aspose.ms.System.ArgumentException - The path is empty, contains only white spaces, or contains invalid characters.
        com.aspose.ms.System.IO.PathTooLongException - The specified path, 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 at path contains 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 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:
        path - the path to the archive file
        loadOptions - the options to load archive with
        Throws:
        com.aspose.ms.System.ArgumentNullException - path is null.
        com.aspose.ms.System.SecurityException - The caller does not have the required permission to access.
        com.aspose.ms.System.ArgumentException - The path is empty, contains only white spaces, or contains invalid characters.
        com.aspose.ms.System.IO.PathTooLongException - The specified path, 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 at path contains 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 IsoEntry type constituting the archive.

        Returns:
        entries of IsoEntry type constituting the iso archive
      • 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 ISO
        filePath - 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 ISO
        source - 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 the path is 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 specified path exceeds 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 saved
        saveOptions - 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 the path is 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 specified path exceeds 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 the stream is null.
        com.aspose.ms.System.ArgumentException - Thrown when the stream is 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 saved
        saveOptions - 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 the stream is null.
        com.aspose.ms.System.ArgumentException - Thrown when the stream is 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:
        extractToDirectory in interface IArchive
        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 the destinationDirectory is null.