public class ZipUtils extends Object
Constructor and Description |
---|
ZipUtils() |
Modifier and Type | Method and Description |
---|---|
static void |
addFileToZip(File file,
ZipOutputStream out,
WaitingHandler waitingHandler,
long totalUncompressedFileSize)
Adds a new file to the zip stream.
|
static void |
addFileToZip(String subDirectory,
File file,
ZipOutputStream out,
WaitingHandler waitingHandler,
long totalUncompressedFileSize)
Adds a new file to the zip stream.
|
static void |
addFolderToZip(String folderPath,
ZipOutputStream out)
Adds a new entry to the zip file corresponding to a new folder.
|
static void |
addToZip(File file,
String subDirectory,
ZipOutputStream out,
WaitingHandler waitingHandler,
long totalUncompressedFileSize)
Adds a new file to the zip stream.
|
static void |
addToZip(File file,
ZipOutputStream out,
WaitingHandler waitingHandler,
long totalUncompressedFileSize)
Adds a new file to the zip stream.
|
static void |
unzip(File zipFile,
File destinationFolder,
WaitingHandler waitingHandler)
Unzips the content of an archive into a given folder.
|
static void |
zip(File originFile,
File destinationFile,
WaitingHandler waitingHandler,
long totalUncompressedFileSize)
Zips a file.
|
public static void zip(File originFile, File destinationFile, WaitingHandler waitingHandler, long totalUncompressedFileSize) throws IOException
originFile
- the file to zip, can be a folderdestinationFile
- the destination filewaitingHandler
- a waiting handler allowing canceling the process
(can be null)totalUncompressedFileSize
- the total uncompressed size, a value
less than 0 will result in an indeterminate progress barIOException
- if an IOException occurspublic static void addToZip(File file, ZipOutputStream out, WaitingHandler waitingHandler, long totalUncompressedFileSize) throws IOException
file
- the file to add to the zipout
- the zip streamwaitingHandler
- a waiting handler allowing canceling the process
(can be null)totalUncompressedFileSize
- the total uncompressed size, a value
less than 0 will result in an indeterminate progress barFileNotFoundException
- if a FileNotFoundException occursIOException
- if an IOException occurspublic static void addToZip(File file, String subDirectory, ZipOutputStream out, WaitingHandler waitingHandler, long totalUncompressedFileSize) throws IOException
subDirectory
- the subdirectory relative to the zip file location
(e.g. "data", note that there is no tailing "/")file
- the file to add to the zipout
- the zip streamwaitingHandler
- a waiting handler allowing canceling the process
(can be null)totalUncompressedFileSize
- the total uncompressed size, a value
less than 0 will result in an indeterminate progress barFileNotFoundException
- if a FileNotFoundException occursIOException
- if an IOException occurspublic static void addFileToZip(File file, ZipOutputStream out, WaitingHandler waitingHandler, long totalUncompressedFileSize) throws IOException
file
- the file to add to the zipout
- the zip streamwaitingHandler
- a waiting handler allowing canceling the process
(can be null)totalUncompressedFileSize
- the total uncompressed size, a value
less than 0 will result in an indeterminate progress barFileNotFoundException
- if a FileNotFoundException occursIOException
- if an IOException occurspublic static void addFileToZip(String subDirectory, File file, ZipOutputStream out, WaitingHandler waitingHandler, long totalUncompressedFileSize) throws IOException
subDirectory
- the subdirectory relative to the zip file location
(e.g. "data", note that there is no tailing "/")file
- the file to add to the zipout
- the zip streamwaitingHandler
- a waiting handler allowing canceling the process
(can be null)totalUncompressedFileSize
- the total uncompressed size, a value
less than 0 will result in an indeterminate progress barFileNotFoundException
- if a FileNotFoundException occursIOException
- if an IOException occurspublic static void addFolderToZip(String folderPath, ZipOutputStream out) throws IOException
folderPath
- the path to the folder relative to the zip file (e.g.
"data", note that there is no tailing "/")out
- the zip streamIOException
- if an IOException occurspublic static void unzip(File zipFile, File destinationFolder, WaitingHandler waitingHandler) throws IOException
zipFile
- the file to unzipdestinationFolder
- the destination folderwaitingHandler
- a waiting handler displaying progress and allowing
canceling the process (can be null)IOException
- if an IOException occursCopyright © 2016. All rights reserved.