LhaArchive

Inheritance: java.lang.Object

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

public class LhaArchive implements IArchive, AutoCloseable

This class represents a LHA (.lzh) archive file.

Only the 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 an entry list can be extracted from the archive.
LhaArchive(InputStream sourceStream, LhaLoadOptions loadOptions)Initializes a new instance of the LhaArchive class and composes an entry list can be extracted from the archive.
LhaArchive(String path)Initializes a new instance of the LhaArchive class and composes an entry list can be extracted from the archive.
LhaArchive(String path, LhaLoadOptions loadOptions)Initializes a new instance of the LhaArchive class and composes an entry 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.
getEntries()Gets file entries of LhaArchiveEntry type constituting the archive.
getFileEntries()Gets entries of IArchiveFileEntry type constituting the archive.
getFormat()Gets the archive format.

LhaArchive(InputStream sourceStream)

public LhaArchive(InputStream sourceStream)

Initializes a new instance of the LhaArchive class and composes an entry 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(InputStream sourceStream, LhaLoadOptions loadOptions)

public LhaArchive(InputStream sourceStream, LhaLoadOptions loadOptions)

Initializes a new instance of the LhaArchive class and composes an entry 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
loadOptionsLhaLoadOptionsOptions to load existing archive with.

LhaArchive(String path)

public LhaArchive(String path)

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

The following example extracts 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.extract(OutputStream) method for decompressing.

Parameters:

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

LhaArchive(String path, LhaLoadOptions loadOptions)

public LhaArchive(String path, LhaLoadOptions loadOptions)

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

The following example extracts 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.extract(OutputStream) method for decompressing.

Parameters:

ParameterTypeDescription
pathjava.lang.Stringthe fully qualified or the relative path to the archive file
loadOptionsLhaLoadOptionsOptions to load existing archive with.

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 |

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.

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

getFormat()

public final ArchiveFormat getFormat()

Gets the archive format.

Returns: ArchiveFormat - the archive format