0

我的 Web 应用程序项目 (JBoss AS) 需要读取驻留在该项目之外的文件。例如,要读取的文件在 /tmp/ 下。

项目中的类似乎无法访问 /tmp/ 下的文件。但是,它可以输出到 /tmp/ 中的文件。

这是正常的吗?如何访问 Web 应用程序中的 /tmp/ 目录?

4

1 回答 1

0

使用java.io.tmpdir系统属性。

File tmpDir = new File(System.getProperty("java.io.tmpdir"));
//Use tmpDir to access files in tmp directory

确保有 unix 权限来读取/写入 tmp 目录上的内容。

于 2015-10-29T06:36:08.673 回答