LhaArchive

Inheritance: java.lang.Object

All Implemented Interfaces: com.aspose.zip.IArchive, java.lang.AutoCloseable

public class LhaArchive implements IArchive, AutoCloseable

This class represents LHA (.lzh) archive file.

Only following compression methods are supported:

| ------ | --------------------------------------------- |
| Method | Explanation                                   |
| lh0    | Uncompressed                                  |
| lh4    | 8 KiB sliding dictionary and static Huffman   |
| lh5    | 16 KiB sliding dictionary and static Huffman  |
| lh6    | 64 KiB sliding dictionary and static Huffman  |
| lh7    | 128 KiB sliding dictionary and static Huffman |
| lhx    | 1 Mib sliding dictionary and static Huffman   |
| lhd    | Directory                                     |

Constructors

ConstructorDescription
LhaArchive(InputStream sourceStream)Initializes a new instance of the LhaArchive class and composes entries list can be extracted from the archive.
LhaArchive(String path)Initializes a new instance of the LhaArchive class and composes entries list can be extracted from the archive.

Methods

MethodDescription
close(){@inheritDoc}
extractToDirectory(String destinationDirectory)Extracts all the files and directories in the archive to the directory provided.
getDirectories()Gets directory entries of LhaDirectoryEntry type constituting the archive.
getEntries()Gets file entries of LhaArchiveEntry type constituting the archive.
getFileEntries()Gets entries of IArchiveFileEntry type constituting the archive.

LhaArchive(InputStream sourceStream)

public LhaArchive(InputStream sourceStream)

Initializes a new instance of the LhaArchive class and composes entries list can be extracted from the archive.

This constructor does not decompress any entry. See LhaArchiveEntry.extract(OutputStream) method for decompressing.

Parameters:

ParameterTypeDescription
sourceStreamjava.io.InputStreamthe source of the archive

LhaArchive(String path)

public LhaArchive(String path)

Initializes a new instance of the LhaArchive class and composes entries list can be extracted from the archive.

The following example extract an archive, then decompress first entry to a MemoryStream.


     ByteArrayOutputStream extracted = new ByteArrayOutputStream();
     try (LhaArchive archive = new LhaArchive("sample.lzh")) {
         archive.getEntries().get(0).extract(extracted);
     }
 

This constructor does not decompress any entry. See ArchiveEntry.open() method for decompressing.

Parameters:

ParameterTypeDescription
pathjava.lang.Stringthe fully qualified or the relative path to the archive file

close()

public void close()

extractToDirectory(String destinationDirectory)

public final void extractToDirectory(String destinationDirectory)

Extracts all the files and directories in the archive to the directory provided.


     try (LhaArchive archive = new LhaArchive("archive.lzh")) {
         archive.extractToDirectory("C:/extracted");
     }
 

Parameters:

ParameterTypeDescription
destinationDirectoryjava.lang.Stringthe path to the directory to place the extracted files in.

If the directory does not exist, it will be created |

getDirectories()

public final List<LhaDirectoryEntry> getDirectories()

Gets directory entries of LhaDirectoryEntry type constituting the archive.

Returns: java.util.List<com.aspose.zip.LhaDirectoryEntry> - directory entries of LhaDirectoryEntry type constituting the archive

getEntries()

public final List<LhaArchiveEntry> getEntries()

Gets file entries of LhaArchiveEntry type constituting the archive.

Returns: java.util.List<com.aspose.zip.LhaArchiveEntry> - file entries of LhaArchiveEntry type constituting the archive

getFileEntries()

public final Iterable<IArchiveFileEntry> getFileEntries()

Gets entries of IArchiveFileEntry type constituting the archive.

Archives for compression only, such as gzip, bzip2, lzip, lzma, xz, z consist of the single record - the archive itself.

Returns: java.lang.Iterable<com.aspose.zip.IArchiveFileEntry> - entries of IArchiveFileEntry type constituting the archive