code: public static void compress(File source, File target) throws IOException {
  
          ZipOutputStream zipOut = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(target)));
          ZipEntry zipEntry = new ZipEntry(source.getName());
          zipOut.putNextEntry(zipEntry);
          BufferedInputStream bis = new BufferedInputStream(new FileInputStream(source), BUFFER);
          byte data[] = new byte[BUFFER];
  
          int count = 0;
          while ((count = bis.read(data, 0, BUFFER)) != -1) {
              zipOut.write(data, 0, count);
          }
          bis.close();
          zipOut.close();
  
      }
docs: Compresses a single file (source) and prepares a zip file (target)
  
  @param source
  @param target
  @throws IOException