code: public static void compress(String folderPath, String zipFilePath) throws IOException {
      File folder = new File(folderPath);
      if (!folder.exists() || !folder.isDirectory()) {
        throw new IOException("Folder " + folderPath + " does't exist or isn't a directory");
      }
  
      File zipFile = new File(zipFilePath);
      if (!zipFile.exists()) {
        File zipFolder = zipFile.getParentFile();
        if (!zipFolder.exists()) {
          if (!zipFolder.mkdirs()) {
            throw new IOException("Zip folder " + zipFolder.getAbsolutePath() + " not created");
          }
        }
        if (!zipFile.createNewFile()) {
          throw new IOException("Zip file " + zipFilePath + " not created");
        }
      }
  
      BufferedInputStream bis;
      ZipOutputStream zos = new ZipOutputStream(
          new BufferedOutputStream(new FileOutputStream(zipFile)));
      try {
        final int BUFFER_SIZE = 8 * 1024; // 8K
        byte buffer[] = new byte[BUFFER_SIZE];
        for (String fileName : folder.list()) {
          if (fileName.equals(".") || fileName.equals("..")) {
            continue;
          }
  
          File file = new File(folder, fileName);
          if (!file.isFile()) {
            continue;
          }
  
          FileInputStream fis = new FileInputStream(file);
          bis = new BufferedInputStream(fis, BUFFER_SIZE);
          try {
            ZipEntry entry = new ZipEntry(fileName);
            zos.putNextEntry(entry);
            int count;
            while ((count = bis.read(buffer, 0, BUFFER_SIZE)) != -1) {
              zos.write(buffer, 0, count);
            }
          } finally {
            try {
              bis.close();
            } catch (IOException e) {
              // Ignore
            }
          }
        }
      } finally {
        try {
          zos.close();
        } catch (IOException e) {
          // Ignore
        }
      }
    }
docs: Compress all files under the specific folder to a single zip file.
  <p>
  Should be call in background thread.
  
  @param folderPath  the specific folder path
  @param zipFilePath the zip file path
  @throws IOException if any error occurs
  @since 2.14.0