我正在尝试访问文件“J:\Java\NetBeansProjects\List of forgoten things\list.eml”并使用操作系统定义的默认应用程序打开它。这可以通过调用在命令提示符中完成
cd "J:\Java\NetBeansProjects\List of forgoten things"
"list.eml"
所以我决定使用
Runtime.getRuntime().exec("cd \"" + System.getProperty("user.dir") + "\"\n\r" + "\"" + selectedFile.getName() + "\"");
但它一直给我一个 IOException:
java.io.IOException: Cannot run program "cd": CreateProcess error=2, The system cannot find the file specified
有没有人想分享任何经验或建议?