在我的Temp
文件夹中,有一个从浏览器下载的文件。我正在尝试使用Desktop
这样的 API 打开此文件:
File f = new File("C:/DOCUME~1/NJAGAD~1/LOCALS~1/Temp/7870249-0/1234567.pptx");
try {
Desktop.getDesktop().open(f);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
但它给出了如下错误:
java.io.IOException: Failed to open file:/C:/DOCUME~1/NJAGAD~1/LOCALS~1/Temp/7870249-0/1234567. Error message: Access is denied.
at sun.awt.windows.WDesktopPeer.ShellExecute(Unknown Source)
at sun.awt.windows.WDesktopPeer.open(Unknown Source)
at java.awt.Desktop.open(Unknown Source)