【发布时间】:2016-01-05 12:36:24
【问题描述】:
在 Linux 系统 (RHEL) 中使用文件阅读器时,以下语句无法找到文件,相同的 cod 在 Windows 环境中工作正常。
此代码在一个我无法修改的 jar 文件中抵抗这是代码的 sn-p
String fileInput = System.getProperty("filelocation");
BufferedReader inputReader = new BufferedReader(new FileReader(fileInput));
属性"filelocation"被传递为
"/home/admin/Downloads/tools/bin/configuration.txt"
或
"file:///home/admin/Downloads/tools/bin/configuration.txt"
错误日志是
(No such file or directory)
java.io.FileNotFoundException: /home/admin/Downloads/tools/bin/configuration.txt
(No such file or directory)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:146)
at java.io.FileInputStream.<init>(FileInputStream.java:101)
at java.io.FileReader.<init>(FileReader.java:58)
at com.mycode.Config.readAppConfig(config.java:123)
【问题讨论】:
-
System.out.println(new File("/home/admin/Downloads/tools/bin/configuration.txt").exists());打印什么? -
您是否以“管理员”身份运行程序?
-
它的打印是真的,来自我的新程序
-
是的,我正在使用管理员帐户
标签: java linux filenotfoundexception file-handling