67,513
社区成员
发帖
与我相关
我的任务
分享
//使用winrar命令行解压缩
String cmd = rarPath + "\\WinRAR.exe x -ibck -y " + SourcePath + "\\" + Filename + " " + SourcePath;
// 第二步:执行解压缩
//java中调用命令行语句
try {
//判断是否解压成功
Process proc;
proc = Runtime.getRuntime().exec(cmd);
if (proc.waitFor() != 0) {
throw new Exception("解压文件'" + Filename + "'错误。错误原因exit value =" + proc.exitValue());
}
File theFile = new File(SourcePath + "\\" + Filename);
theFile.delete();
} catch (Exception e) {
throw new Exception(e);
}