简体   繁体   中英

Open Explorer - java

In one of my java swing application, I am dynamically open windows share folder. Now I want to open it using explorer. So can you guys please help me out to solve it.

如果您使用的是Java 6,最好的方法是使用Desktop

Desktop.getDesktop().open(new File(path));

在Windows(XP / Vista)中,以下代码将起作用:

Runtime.getRuntime().exec("explorer /select,  " + folder);

I would advise against this .getRuntime() ... approach if you have a large application. This approach forks the process, so if you are running this from a large program (eg, within an application server) the fork can eat up your entire available RAM.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM