关于文件操作的简单问题!!!
import java.io.*;
public class qq {
public static void main(String[] args)throws Exception {
File file = new File( "E:\\Downloads\\hotfix ");
File[] tempFile = file.listFiles();
Runtime r=Runtime.getRuntime();
for(int i = 0;i <tempFile.length;i++)
{
if(tempFile[i].isFile())
{ String fileName=tempFile[i].getName();
System.out.println( "File " +fileName+ " is running!! ");
Process p=r.exec(fileName);
System.out.println( "return value is "+p.exitValue());
}
}
}
}
在E:\Downloads\hotfix中有几个exe文件,我想按顺序执行,但第一个
Windows-KB890830-V1.24.exe就出现了问题,如下:
--------------------Configuration: <Default> --------------------
File Windows-KB890830-V1.24.exe is running!!
Exception in thread "main "
java.io.IOException: Cannot run program "Windows-KB890830-V1.24.exe ": CreateProcess error=2, ?????????
at java.lang.ProcessBuilder.start(ProcessBuilder.java:459)
at java.lang.Runtime.exec(Runtime.java:593)
at java.lang.Runtime.exec(Runtime.java:431)
at java.lang.Runtime.exec(Runtime.java:328)
at qq.main(qq.java:15)
Caused by: java.io.
IOException: CreateProcess error=2, ?????????
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl. <init> (ProcessImpl.java:81)
at java.lang.ProcessImpl.start(ProcessImpl.java:30)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:452)
该怎么解决啊,谢谢了
------解决方案--------------------这个文件确实能运行吗?