Class CompressUtil

java.lang.Object
jp.ecuacion.tool.housekeepfiles.util.CompressUtil

public class CompressUtil extends Object
Provides zip and unzip function.
  • Constructor Details

    • CompressUtil

      public CompressUtil()
  • Method Details

    • zipDirectory

      public void zipDirectory(String fromDirPath, String toFilePath) throws IOException
      default encoding is set to "UTF-8".
      Throws:
      IOException
    • zipDirectory

      public void zipDirectory(String fromDirPath, String toFilePath, String encoding) throws IOException
      Zip files in specified directory and create zip file.
      Parameters:
      fromDirPath - directory to be archived (for example: C:/sample)
      toFilePath - zipfile fullpath (for example: C:/sample.zip)
      encoding - "Shift-JIS", "UTF-8", etc...
      Throws:
      IOException
    • zipFile

      public void zipFile(String fromFilePath, String toFilePath) throws IOException
      default encoding is set to "UTF-8".
      Throws:
      IOException
    • zipFile

      public void zipFile(String fromFilePath, String toFilePath, String encoding) throws IOException
      Zip specified file.
      Throws:
      IOException
    • zipFileList

      public void zipFileList(List<String> fromFileList, String filePath) throws IOException
      default encoding is set to "UTF-8".
      Throws:
      IOException
    • zipFileList

      public void zipFileList(List<String> fromFileList, String filePath, String encoding) throws IOException
      Executes zip-archive files specified by ArrayList and create zip file.
      Parameters:
      fromFileList - file list to archive (for example: {C:/sample1.txt, C:/sample2.txt})
      filePath - zipfile fullpath (for example: C:/sample.zip)
      Throws:
      IOException
    • unzip

      public void unzip(String fromFullFilePath, String toFullDirPath) throws IOException
      Provides unzip function.

      This method uses java.util.zip.ZipEntry considering backward compatibility. Notice that this app mainly uses org.apache.tools.zip.ZipEntry.

      Throws:
      IOException