簡體   English   中英

Linux java沒有此類文件或目錄,java.io.FileNotFoundException:

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM