public class Zips extends Object
Modifier and Type | Method and Description |
---|---|
Zips |
addEntries(ZipEntrySource[] entries)
Specifies entries to add or change to the output when this Zips executes.
|
Zips |
addEntry(ZipEntrySource entry)
Specifies an entry to add or change to the output when this Zips executes.
|
Zips |
addFile(File file)
Adds a file entry.
|
Zips |
addFile(File file,
boolean preserveRoot)
Adds a file entry.
|
Zips |
addFile(File file,
boolean preserveRoot,
FileFilter filter)
Adds a file entry.
|
Zips |
addFile(File file,
FileFilter filter)
Adds a file entry.
|
Zips |
addTransformer(String path,
ZipEntryTransformer transformer)
Registers a transformer for a given entry.
|
Zips |
charset(Charset charset)
Specifies charset for this Zips execution
|
boolean |
containsEntry(String name)
Alias to ZipUtil.containsEntry()
|
static Zips |
create()
Static factory method to obtain an instance of Zips without source file.
|
Zips |
destination(File destination)
Specifies destination file for this Zips execution,
if destination is null (default value), then source file will be overwritten.
|
static Zips |
get(File src)
Static factory method to obtain an instance of Zips.
|
byte[] |
getEntry(String name)
Alias to ZipUtil.getEntry()
|
void |
iterate(ZipEntryCallback zipEntryCallback)
Reads the source ZIP file and executes the given callback for each entry.
|
void |
iterate(ZipInfoCallback callback)
Scans the source ZIP file and executes the given callback for each entry.
|
Zips |
nameMapper(NameMapper nameMapper) |
Zips |
preserveTimestamps()
Enables timestamp preserving for this Zips execution
|
void |
process()
Iterates through source Zip entries removing or changing them according to
set parameters.
|
Zips |
removeEntries(String[] entries)
Specifies entries to remove to the output when this Zips executes.
|
Zips |
removeEntry(String entry)
Specifies an entry to remove to the output when this Zips executes.
|
Zips |
setPreserveTimestamps(boolean preserve)
Specifies timestamp preserving for this Zips execution
|
Zips |
unpack() |
public static Zips get(File src)
src
- zip file to processpublic static Zips create()
get(File src)
.public Zips addEntry(ZipEntrySource entry)
entry
- entry to addpublic Zips addEntries(ZipEntrySource[] entries)
entries
- entries to addpublic Zips addFile(File file)
file
- file to add.public Zips addFile(File file, boolean preserveRoot)
file
- file to add.preserveRoot
- if file is a directory, true indicates we want to preserve this dir in the zip.
otherwise children of the file are added directly under root.public Zips addFile(File file, FileFilter filter)
file
- file to add.filter
- a filter to accept files for adding, null means all files are acceptedpublic Zips addFile(File file, boolean preserveRoot, FileFilter filter)
file
- file to add.preserveRoot
- if file is a directory, true indicates we want to preserve this dir in the zip.
otherwise children of the file are added directly under root.filter
- a filter to accept files for adding, null means all files are acceptedpublic Zips removeEntry(String entry)
entry
- path of the entry to removepublic Zips removeEntries(String[] entries)
entries
- paths of the entry to removepublic Zips preserveTimestamps()
public Zips setPreserveTimestamps(boolean preserve)
preserve
- flag to preserve timestampspublic Zips charset(Charset charset)
charset
- charset to usepublic Zips destination(File destination)
destination
- charset to usepublic Zips nameMapper(NameMapper nameMapper)
nameMapper
- to use when processing entriespublic Zips unpack()
public Zips addTransformer(String path, ZipEntryTransformer transformer)
path
- entry to transformtransformer
- transformer for the entrypublic void process()
public void iterate(ZipEntryCallback zipEntryCallback)
For each entry the corresponding input stream is also passed to the callback. If you want to stop the loop then throw a ZipBreakException. This method is charset aware and uses Zips.charset.
zipEntryCallback
- callback to be called for each entry.ZipEntryCallback
public void iterate(ZipInfoCallback callback)
Only the meta-data without the actual data is read. If you want to stop the loop then throw a ZipBreakException. This method is charset aware and uses Zips.charset.
callback
- callback to be called for each entry.ZipInfoCallback
,
iterate(ZipEntryCallback)
public byte[] getEntry(String name)
name
- name of the entry to fetch bytes frompublic boolean containsEntry(String name)
name
- entry to check existence ofCopyright © 2017 ZeroTurnaround. All rights reserved.