Class LzxArchive
- java.lang.Object
-
- com.aspose.zip.LzxArchive
-
- All Implemented Interfaces:
IArchive,AutoCloseable
public class LzxArchive extends Object implements IArchive, AutoCloseable
This class represents a LZX (.lzx) archive file.
-
-
Constructor Summary
Constructors Constructor Description LzxArchive(InputStream extractionSource)Initializes a new instance of theLzxArchiveclass and composes an entry list can be extracted from the archive.LzxArchive(InputStream extractionSource, LzxLoadOptions loadOptions)Initializes a new instance of theLzxArchiveclass and composes an entry list can be extracted from the archive.LzxArchive(String path)Initializes a new instance of theLzxArchiveclass and composes an entry list can be extracted from the archive.LzxArchive(String path, LzxLoadOptions loadOptions)Initializes a new instance of theLzxArchiveclass and composes an entry list can be extracted from the archive.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()voidextractToDirectory(String destinationDirectory)Extracts all the files and directories in the archive to the directory provided.List<LzxArchiveEntry>getEntries()Gets file entries ofLzxArchiveEntrytype constituting the archive.Iterable<IArchiveFileEntry>getFileEntries()Gets entries ofIArchiveFileEntrytype constituting the archive.ArchiveFormatgetFormat()Gets the archive format.
-
-
-
Constructor Detail
-
LzxArchive
public LzxArchive(InputStream extractionSource)
Initializes a new instance of the
LzxArchiveclass and composes an entry list can be extracted from the archive.This constructor does not decompress any entry. See
LzxArchiveEntry.extract(OutputStream)method for decompressing.- Parameters:
extractionSource- The source of the archive.- Throws:
com.aspose.ms.System.ArgumentNullException-extractionSourceis null.com.aspose.ms.System.ArgumentException-extractionSourcedoes not support seeking.com.aspose.ms.System.IO.InvalidDataException- Wrong signature for archive. - or - The file is not a LZX archive.com.aspose.ms.System.NotImplementedException- Lzx archive contains merged entries.com.aspose.ms.System.IO.EndOfStreamException- TheextractionSourcestream is too short.
-
LzxArchive
public LzxArchive(InputStream extractionSource, LzxLoadOptions loadOptions)
Initializes a new instance of the
LzxArchiveclass and composes an entry list can be extracted from the archive.This constructor does not decompress any entry. See
LzxArchiveEntry.extract(OutputStream)method for decompressing.- Parameters:
extractionSource- The source of the archive.loadOptions- Options to load existing archive with.- Throws:
com.aspose.ms.System.ArgumentNullException-extractionSourceis null.com.aspose.ms.System.ArgumentException-extractionSourcedoes not support seeking.com.aspose.ms.System.IO.InvalidDataException- Wrong signature for archive. - or - The file is not a LZX archive.com.aspose.ms.System.NotImplementedException- Lzx archive contains merged entries.com.aspose.ms.System.IO.EndOfStreamException- TheextractionSourcestream is too short.
-
LzxArchive
public LzxArchive(String path)
Initializes a new instance of the
LzxArchiveclass 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 (LzxArchive archive = new LzxArchive("sample.lzx")) { archive.getEntries().get(0).extract(extracted); }This constructor does not decompress any entry. See
LzxArchiveEntry.extract(OutputStream)method for decompressing.- Parameters:
path- The fully qualified or the relative 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.InvalidDataException- The file is corrupted.com.aspose.ms.System.NotImplementedException- Lzx archive contains merged entries.com.aspose.ms.System.IO.EndOfStreamException- The file is too short.
-
LzxArchive
public LzxArchive(String path, LzxLoadOptions loadOptions)
Initializes a new instance of the
LzxArchiveclass 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 (LzxArchive archive = new LzxArchive("sample.lzx")) { archive.getEntries().get(0).extract(extracted); }This constructor does not decompress any entry. See
LzxArchiveEntry.extract(OutputStream)method for decompressing.- Parameters:
path- The fully qualified or the relative path to the archive file.loadOptions- Options to load existing 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.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.InvalidDataException- The file is corrupted.com.aspose.ms.System.NotImplementedException- Lzx archive contains merged entries.com.aspose.ms.System.IO.EndOfStreamException- The file is too short.
-
-
Method Detail
-
getEntries
public final List<LzxArchiveEntry> getEntries()
Gets file entries of
LzxArchiveEntrytype constituting the archive.- Returns:
- file entries of
LzxArchiveEntrytype constituting the archive.
-
getFileEntries
public final Iterable<IArchiveFileEntry> getFileEntries()
Gets entries of
IArchiveFileEntrytype constituting the archive.- Specified by:
getFileEntriesin interfaceIArchive- Returns:
- entries of
IArchiveFileEntrytype constituting the archive
-
getFormat
public final ArchiveFormat getFormat()
Gets the archive format.
-
extractToDirectory
public final void extractToDirectory(String destinationDirectory)
Extracts all the files and directories in the archive to the directory provided.
try (LzxArchive archive = new LzxArchive("archive.lzx")) { archive.extractToDirectory("C:/extracted"); }- Specified by:
extractToDirectoryin interfaceIArchive- Parameters:
destinationDirectory- The path to the directory to place the extracted files in.If the directory does not exist, it will be created.
- Throws:
com.aspose.ms.System.ArgumentNullException-destinationDirectoryis null.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.SecurityException- The caller does not have the required permission to access the existing directory.com.aspose.ms.System.NotSupportedException- If the directory does not exist, the path contains a colon character (:) that is not part of a drive label ("C:\").com.aspose.ms.System.ArgumentException-destinationDirectoryis a zero-length string, contains only white space, or contains one or more invalid characters.com.aspose.ms.System.IO.IOException- The directory specified by path is a file. -or- The network name is not known.com.aspose.ms.System.ObjectDisposedException- Archive has been disposed and cannot be used.com.aspose.ms.System.IO.InvalidDataException- Wrong password has been supplied. - or - Archive is corrupted.com.aspose.ms.System.NotSupportedException- Invalid compression method.com.aspose.ms.System.OperationCanceledException- Thrown when the extraction is canceled via the provided cancellation token.
-
close
public void close()
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceIArchive
-
-