public class TestZip {
public static String SERPEROT = "/";
public static int BUFFER = 2048;
public static void main(String args[]){
zip("e:/hello/", "e:/hello.zip");
}
public static void zip(String srcFile, String descFile){
ZipOutputStream zos = null;
FileOutputStream fos = null;
File file = null;
try {
fos = new FileOutputStream(descFile);
zos = new ZipOutputStream(fos);
file = new File(srcFile);
String folder = srcFile.substring(srcFile.lastIndexOf("/") +1,srcFile.length());
zip(zos,file,folder);
} catch (FileNotFoundException e) {
e.printStackTrace();
}finally{
try{
if(zos != null){zos.close();}
if(fos != null){fos.close();}
}catch(Exception e){
e.printStackTrace();
}
}
}