<分区>
我有一个文件列表。让我们说它看起来:
String[] lst = new String[] {
"C:\\Folder\\file.txt",
"C:\\Another folder\\another file.pdf"
};
我需要一些方法来使用默认程序打开这些文件,让我们用记事本说“file.txt”,用 AdobeReader 说“另一个文件.pdf”等等。
有人知道吗?
<分区>
我有一个文件列表。让我们说它看起来:
String[] lst = new String[] {
"C:\\Folder\\file.txt",
"C:\\Another folder\\another file.pdf"
};
我需要一些方法来使用默认程序打开这些文件,让我们用记事本说“file.txt”,用 AdobeReader 说“另一个文件.pdf”等等。
有人知道吗?
最佳答案
有一个方法可以做到这一点:
java.awt.Desktop.getDesktop().open(file);
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.
关于java - 打开文件以查看其内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16002926/