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 zipsource,
                             String target)
        This method extracts all entries of a zip-file.
        Parameters:
        zipsource - Path of the zip-file.
        target - Path of the extracted files.
        Returns:
        True if successfully extracted.
      • getEntryBytes

        public byte[] getEntryBytes​(File zipsource,
                                    String entry)
        Read the entry inside the file zip resource.
        Parameters:
        zipsource - File to read inside it
        entry - The entry to be read
        Returns:
        The bytes of the entry
      • getEntryStream

        public InputStream getEntryStream​(File zip,
                                          String entry)
        Read the entry inside the file zip resource.
        Parameters:
        zip - 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)