我正在尝试使用FileReader读取文件
try (FileReader fileReader = new FileReader(logFile.getAbsolutePath())) {
fileReader.read();
}
它说:
Caused by: java.io.FileNotFoundException:
/u01/app/oracle/Oracle/Middleware/Oracle_Home/user_projects/domains/base_domain/servers/managed/logs/managed.out (Permission denied)
at java.io.FileInputStream.open0(Native Method)
at java.io.FileInputStream.open(FileInputStream.java:195)
at java.io.FileInputStream.<init>(FileInputStream.java:138)
at java.io.FileInputStream.<init>(FileInputStream.java:93)
at java.io.FileReader.<init>(FileReader.java:58)
at org.reaction.worker.log.LogReader.checkReadable(LogReader.java:98)
root 用户可以在Shell中读取此文件。
另外,文件的权限如下:
ls -la /u01/app/oracle/Oracle/Middleware/Oracle_Home/user_projects/domains/base_domain/servers/managed/logs/managed.out
-rw-r--r-- 1 oracle dba 16486 Feb 28 17:00 /u01/app/oracle/Oracle/Middleware/Oracle_Home/user_projects/domains/base_domain/servers/managed/logs/managed.out
用户 root 执行代码,我检查了Java中 root 的 user.name 属性的值({{1 }}。
还要确保我在Java(System.getProperty("user.name")
)上对此文件执行了 cat 命令,
有什么想法吗?