Class ZipUtil


  • public class ZipUtil
    extends Object
    This class is for handling with zip-files.
    Version:
    4.0
    Author:
    Marco Meschieri - LogicalDOC
    • Constructor Detail

      • ZipUtil

        public ZipUtil()
      • ZipUtil

        public ZipUtil​(String charset)
    • Method Detail

      • unzip

        public boolean unzip​(String zipFile,
                             String target)
        This method extracts all entries of a zip-file.
        Parameters:
        zipFile - Path of the zip-file.
        target - Path of the extracted files.
        Returns:
        True if successfully extracted.
      • getEntryBytes

        public byte[] getEntryBytes​(File zipFile,
                                    String entry)
        Read 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
      • unzipEntry

        public void unzipEntry​(File zipFile,
                               String entry,
                               File target)
        This method extracts a specific entry of a zip-file.
        Parameters:
        zipFile - File to read inside it
        entry - The entry to be read
        target - The extracted file
      • getEntryStream

        public InputStream getEntryStream​(File zipFile,
                                          String entry)
        Read 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
      • zipFile

        public void zipFile​(File src,
                            File dest)
        Compress a single file
        Parameters:
        src - The source file
        dest - The destination archive file
      • zipFolder

        public void zipFolder​(File inFolder,
                              File outFile)
        Zips a folder into a .zip archive
        Parameters:
        inFolder - the folder to compress
        outFile - the zip file
      • getFileNameCharset

        public String getFileNameCharset()
      • setFileNameCharset

        public void setFileNameCharset​(String fileNameCharset)
      • unGZipUnTar

        public void unGZipUnTar​(File tarGzFile,
                                File targetDir)
        Gunzips and Untars a given .tar.gz file
        Parameters:
        tarGzFile - the .tar.gz file
        targetDir - the target folder to unpack to
      • unGZip

        public void unGZip​(File gzFile,
                           File targetFile)
        UnGunzips a given .gz file
        Parameters:
        gzFile - the .gz file
        targetFile - the target file to unpack to
      • unGZip

        public void unGZip​(InputStream gzStream,
                           File targetFile)
        UnGunzips a given .gz stream
        Parameters:
        gzStream - the .gz stream
        targetFile - the target file to unpack to