我会尝试
Desktop.open(File),其中:
启动关联的应用程序以打开文件。
因此,此代码应该可以解决问题:
if (Desktop.isDesktopSupported()) { try { File myFile = new File("/path/to/file.pdf"); Desktop.getDesktop().open(myFile); } catch (IOException ex) { // no application registered for PDFs }}


