public class ZipFile extends Object
Constructor and Description |
---|
ZipFile(File zipFile)
Creates a new Zip File Object with the input file.
|
ZipFile(String zipFile)
Creates a new Zip File Object with the given zip file path.
|
Modifier and Type | Method and Description |
---|---|
void |
addFile(File sourceFile,
ZipParameters parameters)
Adds input source file to the zip file.
|
void |
addFiles(ArrayList sourceFileList,
ZipParameters parameters)
Adds the list of input files to the zip file.
|
void |
addFolder(File path,
ZipParameters parameters)
Adds the folder in the given file object to the zip file.
|
void |
addFolder(String path,
ZipParameters parameters)
Adds the folder in the given path to the zip file.
|
void |
addStream(InputStream inputStream,
ZipParameters parameters)
Creates a new entry in the zip file and adds the content of the inputstream to the
zip file.
|
void |
createZipFile(ArrayList sourceFileList,
ZipParameters parameters)
Creates a zip file and adds the list of source file(s) to the zip file.
|
void |
createZipFile(ArrayList sourceFileList,
ZipParameters parameters,
boolean splitArchive,
long splitLength)
Creates a zip file and adds the list of source file(s) to the zip file.
|
void |
createZipFile(File sourceFile,
ZipParameters parameters)
Creates a zip file and adds the source file to the zip file.
|
void |
createZipFile(File sourceFile,
ZipParameters parameters,
boolean splitArchive,
long splitLength)
Creates a zip file and adds the source file to the zip file.
|
void |
createZipFileFromFolder(File folderToAdd,
ZipParameters parameters,
boolean splitArchive,
long splitLength)
Creates a zip file and adds the files/folders from the specified folder to the zip file.
|
void |
createZipFileFromFolder(String folderToAdd,
ZipParameters parameters,
boolean splitArchive,
long splitLength)
Creates a zip file and adds the files/folders from the specified folder to the zip file.
|
void |
extractAll(String destPath)
Extracts all the files in the given zip file to the input destination path.
|
void |
extractAll(String destPath,
UnzipParameters unzipParameters)
Extracts all the files in the given zip file to the input destination path.
|
void |
extractFile(FileHeader fileHeader,
String destPath)
Extracts a specific file from the zip file to the destination path.
|
void |
extractFile(FileHeader fileHeader,
String destPath,
UnzipParameters unzipParameters)
Extracts a specific file from the zip file to the destination path.
|
void |
extractFile(FileHeader fileHeader,
String destPath,
UnzipParameters unzipParameters,
String newFileName)
Extracts a specific file from the zip file to the destination path.
|
void |
extractFile(String fileName,
String destPath)
Extracts a specific file from the zip file to the destination path.
|
void |
extractFile(String fileName,
String destPath,
UnzipParameters unzipParameters)
Extracts a specific file from the zip file to the destination path.
|
void |
extractFile(String fileName,
String destPath,
UnzipParameters unzipParameters,
String newFileName)
Extracts a specific file from the zip file to the destination path.
|
String |
getComment()
Returns the comment set for the Zip file
|
String |
getComment(String encoding)
Returns the comment set for the Zip file in the input encoding
|
File |
getFile()
Returns the File object of the zip file
|
FileHeader |
getFileHeader(String fileName)
Returns FileHeader if a file header with the given fileHeader
string exists in the zip model: If not returns null
|
List |
getFileHeaders()
Returns the list of file headers in the zip file.
|
ZipInputStream |
getInputStream(FileHeader fileHeader)
Returns an input stream for reading the contents of the Zip file corresponding
to the input FileHeader.
|
ProgressMonitor |
getProgressMonitor() |
ArrayList |
getSplitZipFiles()
Returns the full file path+names of all split zip files
in an ArrayList.
|
boolean |
isEncrypted()
Checks to see if the zip file is encrypted
|
boolean |
isRunInThread() |
boolean |
isSplitArchive()
Checks if the zip file is a split archive
|
boolean |
isValidZipFile()
Checks to see if the input zip file is a valid zip file.
|
void |
mergeSplitFiles(File outputZipFile)
Merges split zip files into a single zip file without the need to extract the
files in the archive
|
void |
removeFile(FileHeader fileHeader)
Removes the file provided in the input file header from the zip file.
|
void |
removeFile(String fileName)
Removes the file provided in the input paramters from the zip file.
|
void |
setComment(String comment)
Sets comment for the Zip file
|
void |
setFileNameCharset(String charsetName)
Zip4j will encode all the file names with the input charset.
|
void |
setPassword(char[] password)
Sets the password for the zip file
|
void |
setPassword(String password)
Sets the password for the zip file.
Note: For security reasons, usage of this method is discouraged. |
void |
setRunInThread(boolean runInThread) |
public ZipFile(String zipFile) throws ZipException
zipFile
- ZipException
public ZipFile(File zipFile) throws ZipException
zipFile
- ZipException
public void createZipFile(File sourceFile, ZipParameters parameters) throws ZipException
sourceFile
- - File to be added to the zip fileparameters
- - parameters to create the zip fileZipException
public void createZipFile(File sourceFile, ZipParameters parameters, boolean splitArchive, long splitLength) throws ZipException
sourceFile
- - File to be added to the zip fileparameters
- - parameters to create the zip filesplitArchive
- - if archive has to be split or notsplitLength
- - if archive has to be split, then length in bytes at which it has to be splitZipException
public void createZipFile(ArrayList sourceFileList, ZipParameters parameters) throws ZipException
sourceFileList
- - File to be added to the zip fileparameters
- - parameters to create the zip fileZipException
public void createZipFile(ArrayList sourceFileList, ZipParameters parameters, boolean splitArchive, long splitLength) throws ZipException
sourceFileList
- - File to be added to the zip fileparameters
- - zip parameters for this file listsplitArchive
- - if archive has to be split or notsplitLength
- - if archive has to be split, then length in bytes at which it has to be splitZipException
public void createZipFileFromFolder(String folderToAdd, ZipParameters parameters, boolean splitArchive, long splitLength) throws ZipException
folderToAdd
- parameters
- splitArchive
- splitLength
- ZipException
public void createZipFileFromFolder(File folderToAdd, ZipParameters parameters, boolean splitArchive, long splitLength) throws ZipException
folderToAdd
- parameters
- splitArchive
- splitLength
- ZipException
public void addFile(File sourceFile, ZipParameters parameters) throws ZipException
sourceFile
- - File to tbe added to the zip fileparameters
- - zip parameters for this fileZipException
public void addFiles(ArrayList sourceFileList, ZipParameters parameters) throws ZipException
sourceFileList
- parameters
- ZipException
public void addFolder(String path, ZipParameters parameters) throws ZipException
path
- parameters
- ZipException
public void addFolder(File path, ZipParameters parameters) throws ZipException
path
- parameters
- ZipException
public void addStream(InputStream inputStream, ZipParameters parameters) throws ZipException
inputStream
- parameters
- ZipException
public void extractAll(String destPath) throws ZipException
destPath
- ZipException
public void extractAll(String destPath, UnzipParameters unzipParameters) throws ZipException
destPath
- unzipParameters
- ZipException
public void extractFile(FileHeader fileHeader, String destPath) throws ZipException
fileHeader
- destPath
- ZipException
public void extractFile(FileHeader fileHeader, String destPath, UnzipParameters unzipParameters) throws ZipException
fileHeader
- destPath
- unzipParameters
- ZipException
public void extractFile(FileHeader fileHeader, String destPath, UnzipParameters unzipParameters, String newFileName) throws ZipException
fileHeader
- destPath
- unzipParameters
- newFileName
- ZipException
public void extractFile(String fileName, String destPath) throws ZipException
fileName
- destPath
- ZipException
public void extractFile(String fileName, String destPath, UnzipParameters unzipParameters) throws ZipException
fileName
- destPath
- unzipParameters
- ZipException
public void extractFile(String fileName, String destPath, UnzipParameters unzipParameters, String newFileName) throws ZipException
fileName
- destPath
- unzipParameters
- newFileName
- ZipException
public void setPassword(String password) throws ZipException
password
- ZipException
public void setPassword(char[] password) throws ZipException
password
- ZipException
public List getFileHeaders() throws ZipException
ZipException
public FileHeader getFileHeader(String fileName) throws ZipException
fileName
- ZipException
public boolean isEncrypted() throws ZipException
ZipException
public boolean isSplitArchive() throws ZipException
ZipException
public void removeFile(String fileName) throws ZipException
fileName
- ZipException
public void removeFile(FileHeader fileHeader) throws ZipException
fileHeader
- ZipException
public void mergeSplitFiles(File outputZipFile) throws ZipException
outputZipFile
- ZipException
public void setComment(String comment) throws ZipException
comment
- ZipException
public String getComment() throws ZipException
ZipException
public String getComment(String encoding) throws ZipException
encoding
- ZipException
public void setFileNameCharset(String charsetName) throws ZipException
charsetName
- ZipException
public ZipInputStream getInputStream(FileHeader fileHeader) throws ZipException
fileHeader
- ZipException
public boolean isValidZipFile()
public ArrayList getSplitZipFiles() throws ZipException
ZipException
public ProgressMonitor getProgressMonitor()
public boolean isRunInThread()
public void setRunInThread(boolean runInThread)
public File getFile()
Copyright © 2013. All rights reserved.