使用Java中的文件程序从filechooser打开文件

时间:2020-12-25 00:29:51

I want to open a file from filechooser with a file's extension. For exapmle, if a user select the file text.doc, then the word must open this file

我想从filechooser打开一个文件扩展名的文件。例如,如果用户选择文件text.doc,则该单词必须打开此文件

1 个解决方案

#1


Desktop.getDesktop().open(File file)

This will open the file with the default program if there is a default program. If IOException occured then there is no associated application or the associated application fails to be launched.

如果有默认程序,这将使用默认程序打开文件。如果发生IOException,则没有关联的应用程序或关联的应用程序无法启动。

#1


Desktop.getDesktop().open(File file)

This will open the file with the default program if there is a default program. If IOException occured then there is no associated application or the associated application fails to be launched.

如果有默认程序,这将使用默认程序打开文件。如果发生IOException,则没有关联的应用程序或关联的应用程序无法启动。