public class ZipUtil extends java.lang.Object
Constructor and Description |
---|
ZipUtil() |
Modifier and Type | Method and Description |
---|---|
static boolean |
extract(java.lang.String zipFile)
Extract the specified zip file in to default location.
|
static boolean |
extract(java.lang.String zipFile,
java.lang.String outputDirectory)
Extract the specified zip file to the specified destination directory.
|
static void |
isValid(java.lang.String zipFile)
Verify that specified file is a valid ZIP file
|
static boolean |
isValid(java.lang.String zipFile,
boolean showError)
Verify that specified file is a valid ZIP file
|
static byte[] |
pack(byte[] rawData)
Compress the specified array of byte and return packed data
|
static byte[] |
pack(java.util.zip.Deflater packer,
byte[] rawData,
int level)
Compress the specified array of byte with given level of compression and return packed data.
|
static byte[] |
unpack(byte[] packedData)
Uncompress the specified array of byte and return unpacked data
|
static byte[] |
unpack(java.util.zip.Inflater unpacker,
byte[] packedData)
Uncompress the specified array of byte and return unpacked data
|
public ZipUtil()
public static byte[] pack(java.util.zip.Deflater packer, byte[] rawData, int level)
packer
- the packer object, can be null
in which case we create a new Deflater objectrawData
- raw data to compresslevel
- level of compression where 0 is low and 9 is high (use -1 to keep current / use default level)public static byte[] pack(byte[] rawData)
public static byte[] unpack(java.util.zip.Inflater unpacker, byte[] packedData) throws java.util.zip.DataFormatException
unpacker
- the unpacker object, can be null
in which case we create a new Inflater objectpackedData
- packed data to uncompressjava.util.zip.DataFormatException
public static byte[] unpack(byte[] packedData) throws java.util.zip.DataFormatException
java.util.zip.DataFormatException
public static boolean extract(java.lang.String zipFile, java.lang.String outputDirectory)
zipFile
- input zip file nameoutputDirectory
- output directory namepublic static boolean extract(java.lang.String zipFile)
zipFile
- input zip file namepublic static void isValid(java.lang.String zipFile) throws java.io.IOException
zipFile
- input zip file namejava.io.IOException
- if the input file is not a valid zip file.public static boolean isValid(java.lang.String zipFile, boolean showError)
zipFile
- input zip file nameshowError
- indicate if the method should show the error (in the output console) if the verify operation failed.