/*
*解決了含有空格目錄下的錯誤
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;
}
}
}
}