Package com.logicaldoc.util.io
Class ZipUtil
java.lang.Object
com.logicaldoc.util.io.ZipUtil
This class is for handling with zip-files.
- Version:
- 4.0
- Author:
- Marco Meschieri - LogicalDOC
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
addEntry
(File zip, String entry, InputStream content) byte[]
getEntryBytes
(File zipFile, String entry) Read the entry inside the file zip resource.getEntryContent
(File zip, String entry) getEntryStream
(File zipFile, String entry) Read the entry inside the file zip resource.listEntries
(File zipFile) listZipEntries
(File zipFile) void
setFileNameCharset
(String fileNameCharset) long
UnGunzips a given .gz filelong
unGZip
(InputStream is, File target) UnGunzips a given .gz streamvoid
unGZipUnTar
(File tarGzFile, File targetDir) Gunzips and Untars a given .tar.gz fileint
unzip
(InputStream zipStream, String target) This method extracts all entries of a zip-file.long
unzip
(InputStream input, String entry, File target) Extracts a specific entry inside a given zip streamint
This method extracts all entries of a zip-file.long
unzipEntry
(File zipFile, String entry, File target) This method extracts a specific entry of a zip-file.void
Compress a single filevoid
Zips a folder into a .zip archive
-
Constructor Details
-
ZipUtil
public ZipUtil() -
ZipUtil
-
-
Method Details
-
listZipEntries
-
listEntries
-
unzip
This method extracts all entries of a zip-file.- Parameters:
zipFile
- Path of the zip-file.target
- Path of the extracted files.- Returns:
- Number of extracted entries
- Throws:
IOException
- Error unpacking the zip
-
unzip
This method extracts all entries of a zip-file.- Parameters:
zipStream
- the zip contentstarget
- Path of the extracted files.- Returns:
- Number of extracted entries
- Throws:
IOException
- Error unpacking the zip
-
unzip
Extracts a specific entry inside a given zip stream- Parameters:
input
- the stream of the zip fileentry
- name of the entry to extracttarget
- the file where to store the entry- Returns:
- number of written bytes
- Throws:
IOException
- Error unpacking the zip
-
unzipEntry
This method extracts a specific entry of a zip-file. https://github.com/srikanth-lingala/zip4j- Parameters:
zipFile
- File to read inside itentry
- The entry to be readtarget
- The extracted file- Returns:
- number of written bytes
- Throws:
IOException
- Error extracting the zip
-
getEntryBytes
Read the entry inside the file zip resource.- Parameters:
zipFile
- File to read inside itentry
- The entry to be read- Returns:
- The bytes of the entry
-
getEntryStream
Read the entry inside the file zip resource.- Parameters:
zipFile
- File to read inside itentry
- The entry to be read- Returns:
- The stream of the entry
-
getEntryContent
- Throws:
FileNotFoundException
IOException
-
addEntry
-
zipFile
Compress a single file- Parameters:
src
- The source filedest
- The destination archive file
-
zipFolder
Zips a folder into a .zip archive- Parameters:
inFolder
- the folder to compressoutFile
- the zip file
-
getFileNameCharset
-
setFileNameCharset
-
unGZipUnTar
Gunzips and Untars a given .tar.gz file- Parameters:
tarGzFile
- the .tar.gz filetargetDir
- the target folder to unpack to- Throws:
IOException
- An error processing the GZip or Tar
-
unGZip
UnGunzips a given .gz file- Parameters:
gzFile
- the .gz filetargetFile
- the target file to unpack to- Returns:
- size of the written file
- Throws:
IOException
- Error processing the GZip
-
unGZip
UnGunzips a given .gz stream- Parameters:
is
- the .gz streamtarget
- the target file to unpack to- Returns:
- size of the written file
- Throws:
IOException
- Error processing the GZip
-