首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2SE开发 >

java Runtime.exec();该如何解决

2013-03-27 
java Runtime.exec();System.out.println(**************运行可执行文件*********************)try {Fi

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();
        }

热点排行
Bad Request.