开发者

Open Explorer - java

开发者 https://www.devze.com 2023-02-18 18:00 出处:网络
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.开发者_运维知识库If you are using

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.开发者_运维知识库


If you are using Java 6, the best way to do this is to use Desktop:

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


In Windows (XP/Vista) the following code will work:

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 (e.g., within an application server) the fork can eat up your entire available RAM.

0

精彩评论

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