日期:2014-05-20  浏览次数:20662 次

java Runtime.exec();
System.out.println("**************运行可执行文件*********************");
try {
File fr=new File("E:\\workspace","Test.txt");
Runtime rt=Runtime.getRuntime();
rt.exec(fr.getAbsolutePath());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Test。txt是存在的  为什么就不可以操作 ,且报错了
java file

------解决方案--------------------
亲爱的, 像这样就可以了        
try {
            File fr=new File("E:\\workspace","Test.txt");
            Runtime rt = Runtime.getRuntime();
            rt.exec("notepad", new String[]{fr.getAbsolutePath()});
        } catch (IOException e) {
            e.printStackTrace();
        }