LzipArchive

Inheritance: java.lang.Object

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

public class LzipArchive implements IArchive, IArchiveFileEntry, AutoCloseable

This class represents Lzip archive file. Use it to compose or extract Lzip archives.

Constructors

ConstructorDescription
LzipArchive()Initializes a new instance of the LzipArchive.
LzipArchive(LzipArchiveSettings settings)Initializes a new instance of the LzipArchive.
LzipArchive(InputStream sourceStream)Initializes a new instance of the LzipArchive class prepared for decompressing.
LzipArchive(String path)Initializes a new instance of the LzipArchive class prepared for decompressing.

Methods

MethodDescription
close(){@inheritDoc}
extract(File file)Extracts lzip archive to a file.
extract(OutputStream destination)Extracts lzip archive to a stream.
extract(String path)Extracts lzip archive to a file by path.
extractToDirectory(String destinationDirectory)Extracts content of the archive to the directory provided.
getFileEntries()Gets entries of IArchiveFileEntry type constituting the lzip archive.
getLength()Gets length.
getName()The name of original file.
getSettings()Gets the setting of particular lzip archive.
save(File destination)Saves lzip archive to destination file provided.
save(OutputStream outputStream)Saves lzip archive to the stream provided.
save(String destinationFileName)Saves lzip archive to destination file provided.
setSource(File file)Sets the content to be compressed within the archive.
setSource(InputStream source)Sets the content to be compressed within the archive.
setSource(String path)Sets the content to be compressed within the archive.

LzipArchive()

public LzipArchive()

Initializes a new instance of the LzipArchive.

LzipArchive(LzipArchiveSettings settings)

public LzipArchive(LzipArchiveSettings settings)

Initializes a new instance of the LzipArchive.

Parameters:

ParameterTypeDescription
settingsLzipArchiveSettingsthe setting of particular lzip archive with definition of dictionary size

LzipArchive(InputStream sourceStream)

public LzipArchive(InputStream sourceStream)

Initializes a new instance of the LzipArchive class prepared for decompressing.


     try (FileInputStream sourceLzipFile = new FileInputStream("sourceLzipFile")) {
         try (FileOutputStream extractedFile = new FileOutputStream("extractedFileName")) {
             try (LzipArchive archive = new LzipArchive(sourceLzipFile)) {
                 archive.extract(extractedFile);
             }
         }
     } catch (IOException ex) {
     }
 

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

Parameters:

ParameterTypeDescription
sourceStreamjava.io.InputStreamthe source of the archive

LzipArchive(String path)

public LzipArchive(String path)

Initializes a new instance of the LzipArchive class prepared for decompressing.


     try (FileOutputStream extractedFile = new FileOutputStream("extractedFileName")) {
         try (LzipArchive archive = new LzipArchive("sourceLzipFileName")) {
             archive.extract(extractedFile);
         }
     } catch (IOException ex) {
     }
 

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

Parameters:

ParameterTypeDescription
pathjava.lang.Stringthe path to the source of the archive

close()

public void close()

extract(File file)

public final void extract(File file)

Extracts lzip archive to a file.


     try (FileInputStream lzipFile = new FileInputStream("sourceFileName")) {
         try (LzipArchive archive = new LzipArchive(lzipFile)) {
             archive.extract(new File("extracted.bin"));
         }
     } catch (IOException ex) {
     }
 

Parameters:

ParameterTypeDescription
filejava.io.Filethe file for storing decompressed data

extract(OutputStream destination)

public final void extract(OutputStream destination)

Extracts lzip archive to a stream.


     try (FileInputStream sourceLzipFile = new FileInputStream("sourceLzipFile")) {
         try (FileOutputStream extractedFile = new FileOutputStream("extractedFileName")) {
             try (LzipArchive archive = new LzipArchive(sourceLzipFile)) {
                 archive.extract(extractedFile);
             }
         }
     } catch (IOException ex) {
     }
 

Parameters:

ParameterTypeDescription
destinationjava.io.OutputStreamthe stream for storing decompressed data

extract(String path)

public final File extract(String path)

Extracts lzip archive to a file by path.


     try (FileInputStream lzipFile = new FileInputStream("sourceFileName")) {
         try (LzipArchive archive = new LzipArchive(lzipFile)) {
             archive.extract("extracted.bin");
         }
     } catch (IOException ex) {
     }
 

Parameters:

ParameterTypeDescription
pathjava.lang.Stringthe path to the file which will store decompressed data

Returns: java.io.File - the file info of the extracted file

extractToDirectory(String destinationDirectory)

public final void extractToDirectory(String destinationDirectory)

Extracts content of the archive to the directory provided.

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 |

getFileEntries()

public final Iterable<IArchiveFileEntry> getFileEntries()

Gets entries of IArchiveFileEntry type constituting the lzip archive.

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

getLength()

public final Long getLength()

Gets length.

Returns: java.lang.Long - length

getName()

public final String getName()

The name of original file.

Returns: java.lang.String - the name of the original file

getSettings()

public final LzipArchiveSettings getSettings()

Gets the setting of particular lzip archive.

Returns: LzipArchiveSettings - the setting of particular lzip archive

save(File destination)

public final void save(File destination)

Saves lzip archive to destination file provided.


     try (LzipArchive archive = new LzipArchive()) {
         archive.setSource(new File("data.bin"));
         archive.save(new File("archive.lz"));
     }
 

Parameters:

ParameterTypeDescription
destinationjava.io.Filethe file which will be opened as destination stream

save(OutputStream outputStream)

public final void save(OutputStream outputStream)

Saves lzip archive to the stream provided.


     try (FileOutputStream lzFile = new FileOutputStream("archive.lz")) {
         try (LzipArchive archive = new LzipArchive()) {
             archive.setSource("data.bin");
             archive.save(lzFile);
         }
     } catch (IOException ex) {
     }
 

Parameters:

ParameterTypeDescription
outputStreamjava.io.OutputStreamdestination stream

save(String destinationFileName)

public final void save(String destinationFileName)

Saves lzip archive to destination file provided.


     try (LzipArchive archive = new LzipArchive()) {
         archive.setSource(new File("data.bin"));
         archive.save("result.lz");
     }
 

Parameters:

ParameterTypeDescription
destinationFileNamejava.lang.Stringthe path of the archive to be created. If the specified file name points to an existing file, it will be overwritten

setSource(File file)

public final void setSource(File file)

Sets the content to be compressed within the archive.


     try (LzipArchive archive = new LzipArchive()) {
         archive.setSource(new File("data.bin"));
         archive.save("archive.lz");
     }
 

Parameters:

ParameterTypeDescription
filejava.io.Filethe file which will be opened as input stream

setSource(InputStream source)

public final void setSource(InputStream source)

Sets the content to be compressed within the archive.


     try (LzipArchive archive = new LzipArchive()) {
         archive.setSource(new ByteArrayInputStream(new byte[] {0x00, (byte)0xFF} ));
         archive.save("archive.lz");
     }
 

Parameters:

ParameterTypeDescription
sourcejava.io.InputStreamthe input stream for the archive

setSource(String path)

public final void setSource(String path)

Sets the content to be compressed within the archive.


     try (LzipArchive archive = new LzipArchive()) {
         archive.setSource("data.bin");
         archive.save("archive.lz");
     }
 

Parameters:

ParameterTypeDescription
pathjava.lang.Stringthe path to the file to be compressed