public class TestZip {
public static String SERPEROT =
public static int BUFFER =
public static void main(String args[]){
zip(
}
public static void zip(String srcFile
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
zip(zos
} catch (FileNotFoundException e) {
e
}finally{
try{
if(zos != null){zos
if(fos != null){fos
}catch(Exception e){
e
}
}
}
private static void zip(ZipOutputStream descFile
FileInputStream fis = null;
System
try{
if(srcFile
File[] files = srcFile
descFile
srcfolder = srcfolder
System
for(int i=
zip(descFile
}
}else{
descFile
fis = new FileInputStream(srcFile);
byte[] bytes = new byte[
int n =
while((n = fis
descFile
}
}
}catch(Exception e){
e
}finally{
try{
if(fis != null){fis
}catch(Exception e){
e
}
}
}
}
From:http://tw.wingwit.com/Article/program/Java/hx/201311/25760.html