import java.io.*; import java.util.zip.*; import java.util.Vector; import java.util.regex.*; import java.util.Date; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.text.ParseException; public class ZipIt { String zipFolder, zipPath, strDb, fullZipName, folderPath; FileOutputStream fos; ZipOutputStream zOut; String slash; boolean success; int len = 0; //used by buffers to write out the attached files byte b[] = new byte[ 512 ]; ZipIt(){ try { Date now = new Date(); String dateString = now.toString(); SimpleDateFormat format = new SimpleDateFormat("dd-MMM-yyyy_kkmmss"); //This uses the OS's tmp directory (so it can't be downloaded by anyone (outside HTML directory)). //Usually C:\Windows\Temp" folderPath = System.getProperty("java.io.tmpdir"); slash = System.getProperty("file.separator"); //concatenates a short file name with the folder part to create the location for the zip file zipPath = folderPath + slash+ "dext"+slash+"backups"+slash+format.format(now); //the name of the zip file with path, unique zipfolder and zip suffix fullZipName = zipPath + slash+"DEXT_Backup_" + format.format(now) + ".zip"; //Now we know where to, we can setup the required directories on the OS. File dir = new File( zipPath +slash+"articles"); boolean exists = dir.exists(); if( !exists ){ //creates directory; all ancestor directories MUST exist success = ( dir ).mkdirs(); } else { //if directory already exists the code empties its contents if (dir.isDirectory()) { String[] children = dir.list(); if (children.length > 0){ for (int i=0; i