Package com.logicaldoc.util.io
Class ZipUtil
java.lang.Object
com.logicaldoc.util.io.ZipUtil
- All Implemented Interfaces:
- Closeable,- AutoCloseable
This class is for handling with zip-files.
- Version:
- 4.0
- Author:
- Marco Meschieri - LogicalDOC
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic voidaddEntry(File zip, String entry, InputStream content) voidclose()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) voidsetFileNameCharset(String fileNameCharset) longUnGunzips a given .gz filelongunGZip(InputStream is, File target) UnGunzips a given .gz streamvoidunGZipUnTar(File tarGzFile, File targetDir) Gunzips and Untars a given .tar.gz fileintThis method extracts all entries of a zip-file.longThis method extracts a specific entry of a zip-file.intunzip(InputStream zipStream, File target) This method extracts all entries of a zip-file.longunzip(InputStream input, String entry, File target) Extracts a specific entry inside a given zip streamvoidCompress a single filevoidZips a folder into a .zip archive
- 
Constructor Details- 
ZipUtilpublic ZipUtil()
- 
ZipUtil
 
- 
- 
Method Details- 
listZipEntries
- 
listEntries
- 
unzipThis method extracts all entries of a zip-file.- Parameters:
- zipFile- the zip-file
- target- the target folder
- Returns:
- Number of extracted entries
- Throws:
- IOException- Error unpacking the zip
 
- 
unzipThis method extracts all entries of a zip-file.- Parameters:
- zipStream- the zip contents
- target- the target folder
- Returns:
- Number of extracted entries
- Throws:
- IOException- Error unpacking the zip
 
- 
unzipExtracts a specific entry inside a given zip stream- Parameters:
- input- the stream of the zip file
- entry- name of the entry to extract
- target- the file where to store the entry
- Returns:
- number of written bytes
- Throws:
- IOException- Error unpacking the zip
 
- 
unzipThis method extracts a specific entry of a zip-file. https://github.com/srikanth-lingala/zip4j- Parameters:
- zipFile- File to read inside it
- entry- The entry to be read
- target- The extracted file
- Returns:
- number of written bytes
- Throws:
- IOException- Error extracting the zip
 
- 
getEntryBytesRead the entry inside the file zip resource.- Parameters:
- zipFile- File to read inside it
- entry- The entry to be read
- Returns:
- The bytes of the entry
 
- 
getEntryStreamRead the entry inside the file zip resource.- Parameters:
- zipFile- File to read inside it
- entry- The entry to be read
- Returns:
- The stream of the entry
 
- 
closepublic void close()- Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- Closeable
 
- 
getEntryContent- Throws:
- IOException
 
- 
addEntry
- 
zipFileCompress a single file- Parameters:
- src- The source file
- dest- The destination archive file
 
- 
zipFolderZips a folder into a .zip archive- Parameters:
- inFolder- the folder to compress
- outFile- the zip file
 
- 
getFileNameCharset
- 
setFileNameCharset
- 
unGZipUnTarGunzips and Untars a given .tar.gz file- Parameters:
- tarGzFile- the .tar.gz file
- targetDir- the target folder to unpack to
- Throws:
- IOException- An error processing the GZip or Tar
 
- 
unGZipUnGunzips a given .gz file- Parameters:
- gzFile- the .gz file
- targetFile- the target file to unpack to
- Returns:
- size of the written file
- Throws:
- IOException- Error processing the GZip
 
- 
unGZipUnGunzips a given .gz stream- Parameters:
- is- the .gz stream
- target- the target file to unpack to
- Returns:
- size of the written file
- Throws:
- IOException- Error processing the GZip
 
 
-