import java.io.IOException;
public class ZIPTest2 {
public static void main(String[] args) throws Exception {
//
String tool = "C:\\Program Files\\7-Zip\\7z.exe";
String sourcefolder = "E:\\test\\*";
String targetZip = "E:\\test.zip";
String exec = String.format("%s a \"%s\" \"%s\"", tool, targetZip, sourcefolder);
Runtime runtime = Runtime.getRuntime();
Process pro = runtime.exec(exec);
int result = pro.waitFor();
if(result != 0){
System.out.println("init zip error.");
}
pro.destroy();
Thread.sleep(1000);
String addfile = String.format("%s a \"%s\" -aoa \"%s\"", tool, targetZip, "E:\\test2");
pro = runtime.exec(addfile);
result = pro.waitFor();
if(result != 0){
System.out.println("update file .iso error.");
}
pro.destroy();
runtime.freeMemory();
runtime.gc();
}
}
public class ZIPTest2 {
public static void main(String[] args) throws Exception {
//
String tool = "C:\\Program Files\\7-Zip\\7z.exe";
String sourcefolder = "E:\\test\\*";
String targetZip = "E:\\test.zip";
String exec = String.format("%s a \"%s\" \"%s\"", tool, targetZip, sourcefolder);
Runtime runtime = Runtime.getRuntime();
Process pro = runtime.exec(exec);
int result = pro.waitFor();
if(result != 0){
System.out.println("init zip error.");
}
pro.destroy();
Thread.sleep(1000);
String addfile = String.format("%s a \"%s\" -aoa \"%s\"", tool, targetZip, "E:\\test2");
pro = runtime.exec(addfile);
result = pro.waitFor();
if(result != 0){
System.out.println("update file .iso error.");
}
pro.destroy();
runtime.freeMemory();
runtime.gc();
}
}