程序如下,可以运行压缩文件,就是有个问题,会出现winrar的“诊断信息”的提示:!   无法创建 d:\test.rar!   另一个程序正在使用此文件,进程无法访问。
这样的话接下去的其他程序就运行不了
public static boolean zip(String zipfile,String foler){
String rarPath="C:\\Program Files\\WinRAR\\WinRAR.exe";
String cmd=rarPath+" a " + zipfile +" "+ foler;
try{
Runtime.getRuntime().exec(cmd);
Process proc=Runtime.getRuntime().exec(cmd);
if(proc.waitFor() !=0){
if(proc.exitValue()==0)
return true;
}
}catch(Exception e){
e.printStackTrace();
}
return false;
}

解决方案 »

  1.   

    就是在你在用winrar这个程序或者你要解压的文件
    先在进程里面杀掉再试
      

  2.   

    进程里没有占用的程序啊,好像不是这个原因。。
    在dos窗口运行相同命令就没问题
      

  3.   

    Runtime.getRuntime().exec(cmd);
    这行去掉,多余了
      

  4.   

    在调用命令的时候加一个参数" -inul " 这样就不会出现那个诊断框了
    String rarPath="C:\\Program Files\\WinRAR\\WinRAR.exe";
    String cmd=rarPath+" a -inul " + zipfile +" "+ foler;