Class LhaArchiveEntry

    • Method Detail

      • getName

        public final String getName()

        Gets the name of the entry.

        Archives for compression only, such as gzip, bzip2, lzip, lzma, xz, z has name "File.bin" unless another name can be found in headers.

        Specified by:
        getName in interface IArchiveFileEntry
        Returns:
        the name of the entry
      • getLength

        public final Long getLength()

        Gets the length of the entry in bytes.

        Specified by:
        getLength in interface IArchiveFileEntry
        Returns:
        the length of the entry in bytes
      • isDirectory

        public final boolean isDirectory()

        Gets a value indicating whether this entry is a directory.

        Returns:
        a value indicating whether this entry is a directory.
      • getLastModified

        @Deprecated
        public final Date getLastModified()
        Deprecated.
        This method will be removed in a future release. Please use getModificationTime() instead.

        Gets the last modified time of the entry.

        Returns:
        the last modified time of the entry
      • getModificationTime

        public final Date getModificationTime()

        Gets the last modified time of the entry.

        Returns:
        the last modified time of the entry
      • getPath

        public final String getPath()

        Gets the full path to the entry.

        Returns:
        the full path to the entry
      • extract

        public final File extract​(String path)

        Extracts Lha archive entry to a filesystem by path.

        
             try (FileInputStream lhaFile = new FileInputStream("archive.lha")) {
                 try (LhaArchive archive = new LhaArchive(lhaFile)) {
                     archive.getEntries().get(0).extract("extracted.bin");
                 }
             } catch (IOException ex) {
             }
         
        Specified by:
        extract in interface IArchiveFileEntry
        Parameters:
        path - the path to the file which will store decompressed data
        Returns:
        File instance containing extracted data
        Throws:
        com.aspose.ms.System.InvalidOperationException - Archive headers and service information were not read.
        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.
      • extract

        public final void extract​(OutputStream destination)

        Extracts the entry to the stream provided.

        Specified by:
        extract in interface IArchiveFileEntry
        Parameters:
        destination - destination stream
      • extract

        public final void extract​(File file)

        Extracts Lha archive entry to a file.

        
             try (FileInputStream lhaFile = new FileInputStream("archive.lha")) {
                 try (LhaArchive archive = new LhaArchive(lhaFile)) {
                     archive.getEntries().get(0).extract(new File("extracted.bin"));
                 }
             } catch (IOException ex) {
             }
         
        Parameters:
        file - File for storing decompressed data.

        Does nothing for directory entry

        Throws:
        com.aspose.ms.System.InvalidOperationException - Archive headers and service information were not read.
        com.aspose.ms.System.SecurityException - The caller does not have the required permission to open the file.
        com.aspose.ms.System.ArgumentException - The file path is empty or contains only white spaces.
        com.aspose.ms.System.IO.FileNotFoundException - The file is not found.
        com.aspose.ms.System.ArgumentNullException - file is null.
        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.