[英]java.io.FileNotFoundException: .. (No such file or directory)
[英]Linux java No such file or directory, java.io.FileNotFoundException:
在Linux系统(RHEL)中使用文件阅读器时,以下语句无法找到文件,相同的cod在Windows env中可以正常工作。
这段代码包含在一个我无法修改的jar文件中,这是该代码段
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)
它与JAVA无关。 它是由于传递变量的shell脚本而来的
使用语句input_file = $ {input_file:0:$(expr $ {#input_file}-1)}
该语句用于删除字符串的最后一个字符,在我的情况下,这是一个新的Line char,它是不可见的。
感谢表单: https : //unix.stackexchange.com/questions/144298/delete-the-last-character-of-a-string-using-string-manipulation-in-shell-script/144345#144345?newreg = 9e4833bcf644426aaf9f275bf4fd1743
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.