我希望能够根据标题所说的做到。
部分解决方案:
例如在Windows
中,您可以使用以下代码打开默认资源管理器并突出显示文件。
(尽管它需要修改来处理包含空格的文件
):
/**
* Opens the file with the System default file explorer.
*
* @param path the path
*/
public static void openFileLocation(String path) {
if (InfoTool.osName.toLowerCase().contains("win")) {
try {
Runtime.getRuntime().exec("explorer.exe /select," + path);
} catch (IOException ex) {
Main.logger.log(Level.WARNING, ex.getMessage(), ex);
}
}
}
有用的链接:
这些链接类似,但是并不重复或没有回答:
如何使用Java代码打开Windows文件资源管理器并突出显示指定的文件?
更多解释:
Is there a way to do it using JavaFX ?
If not at least i need a link or some way to make the app system independence.I mean i don't know the default explorer for every OS that the application is going to work , i need a link or help doing that.
Do i need to write a ton of code to do this?
Is out there any library for doing that?
Do Java9 support that?
最后:
很奇怪的是,对于如此普遍的事情,我找不到答案和库。
在Windows 10中选择或突出显示的示例: