/*
*解决了含有空格目录下的错误
Runtime.getRuntime().exec("cmd /c" + "D:/1.txt");
/*
public static void openSystemExeFile() {
String strurl ="D:\t.txt";
File crtfle = new File(strurl);
if (crtfle != null && crtfle.exists()) {
int index = strurl.lastIndexOf(".");
String format = strurl.substring(index + 1, strurl.length());
if (format.equals("exe")) {
try {
Runtime.getRuntime().exec(strurl); // 执行系统的exe文件
RegRead rg = RegRead.getInstance();
String filePath2 = "\"" + strurl + "\"";
if (rg.ShellExecute(filePath2, null)) { // appName,
}
String exePath = rg.GetOnlyOpenTool(format);
if (exePath == null || exePath.equals("")) {
return;
}
return;
} catch (IOException ex) {
ex.printStackTrace();
}
} else {
// 如果是可执行.
String formats = substr(strurl).toLowerCase();
if (formats == null || "".equals(formats)) {
return;
}
if (formats.equals("exe")) {
try {
Runtime.getRuntime().exec(strurl);
return;
} catch (IOException ex) {
ex.printStackTrace();
}
} else {
try {
System.out.println(strurl);
Runtime.getRuntime().exec("cmd /c" + strurl);// 文件路径,(cmd
// /c是系统命令)
} catch (IOException e) {
e.printStackTrace();
}
return;
}
}
}
}