开发者

Opening file from Java

What I need is to instruct OS to open the file with the default program used for that file type. Exactly as if, i.e., that file was double-clicked by user under Windows.

The purpose is, i.e., "your PDF file was generated. Click he开发者_JAVA百科re to open it".

In platform-independent way, if possible...

I dont know exact terms for what I want, so if someone could update tags, I'd most appreciate that ;)


You need the Desktop class, and the open() method in particular.

Launches the associated application to open the file. If the specified file is a directory, the file manager of the current platform is launched to open it.


Since Java 6, we have Desktop.open() for exactly that purpose.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜