【发布时间】:2015-03-27 23:33:09
【问题描述】:
我正在开发一个需要打开附件的应用程序。我需要单击“打开”按钮并打开一个 pdf 文件。我这样做的方式是从服务器获取内容并将其写入临时目录上的某个位置。
但是,当我尝试从远程计算机访问此服务时, http://myserverIP:port/openMyAttachment,它访问的是 myserverIP 的临时目录,而不是本地机器。然后它会在 myserverIP 上打开文件。
我正在使用以下代码来获取临时目录:
String tmp = System.getProperty("java.io.tmpdir");
JFileChooser fc = new JFileChooser();
FileSystemView fsv = fc.getFileSystemView();
File f = fsv.getDefaultDirectory();
String dir = f.getAbsolutePath();
String strDirectory = "temp~" + f.separator;
有人可以分享你的想法吗?如何访问本地机器上的临时目录并将文件写入本地机器?
【问题讨论】:
标签: java swing jfilechooser tempdir