code: public static void recursiveAddZip(File parent, ZipOutputStream zout, File fileSource)
        throws IOException {
  
      File[] files = fileSource.listFiles();
  
      for (int i = 0; i < files.length; i++) {
        if (files[i].isDirectory()) {
          recursiveAddZip(parent, zout, files[i]);
          continue;
        }
  
        byte[] buffer = new byte[1024];
  
        FileInputStream fin = new FileInputStream(files[i]);
  
        ZipEntry zipEntry =
            new ZipEntry(files[i].getAbsolutePath()
                .replace(parent.getAbsolutePath(), "").substring(1)); //$NON-NLS-1$
        zout.putNextEntry(zipEntry);
  
        int length;
        while ((length = fin.read(buffer)) > 0) {
          zout.write(buffer, 0, length);
        }
  
        zout.closeEntry();
  
        fin.close();
  
      }
  
    }
docs: Recursively add files to a ZipOutputStream
  
  @param parent Parent file
  @param zout ZipOutputStream to append
  @param fileSource The file source
  @throws IOException I/O Error