开发者

cross platform way to explore the containing folder of a file

开发者 https://www.devze.com 2023-01-23 01:56 出处:网络
is there functionality in java to open the containing folder of a file across any platform. I can accomplis开发者_如何学Pythonh this in windows by running

is there functionality in java to open the containing folder of a file across any platform. I can accomplis开发者_如何学Pythonh this in windows by running

Runtime rt = Runtime.getRuntime();
Process proc = rt.exec("explorer /select,c:\\sampleFile.txt");

You can open a file (if the Desktop api is supported) on any platform with java.awt.Desktop.getDesktop().open(file). Is there something similar to bring up a file manager?

Thanks.


What happens if you call getDesktop().open(file.getParentFile()) ?

0

精彩评论

暂无评论...
验证码 换一张
取 消