1.     private void zipDir(String dir2zip, ZipOutputStream zos){
  2.         try{
  3.           File zipDir = new File(dir2zip);
  4.           String[] dirList = zipDir.list();
  5.          
  6.           byte[] readBuffer = new byte[2156];
  7.           int bytesIn = 0;
  8.          
  9.           for (String file : dirList) {
  10.      
  11.               File f = new File(zipDir, file);
  12.               if (f.isDirectory()) {
  13.                   String filePath = f.getPath();
  14.                   zipDir(filePath, zos);
  15.               }else{
  16.                  
  17.                 FileInputStream fis = new FileInputStream(f);
  18.                 ZipEntry anEntry = new ZipEntry(f.getPath());
  19.                 zos.putNextEntry(anEntry);
  20.                 while ((bytesIn = fis.read(readBuffer)) != -1) {
  21.                     zos.write(readBuffer, 0, bytesIn);
  22.                 }
  23.                 fis.close();
  24.               }
  25.           }
  26.          
  27.           zos.close();
  28.          
  29.         }catch(Exception e){
  30.            
  31.         }}