我怎样才能打开从Java Swing应用程序在默认浏览器的HTML文件?

问题描述:

我的Java Swing应用程序生成一个HTML文件,然后我想时生成并保存它的默认浏览器打开它。我怎样才能做到这一点?

My Java Swing application generates an HTML file, and I want to open it with the default browser when it is generated and saved. How can I do this?

如果您使用的是Java 6,使用Desktop.open().它可以让你打开与该系统上的文件类型关联的默认应用程序的任何文件。

If you are using Java 6, use Desktop.open(). It allows you to open any file with the default application associated with its file type on the system.