簡體   English   中英

從命令行參數讀取文件時出現Java FileNotFoundException

[英]Java FileNotFoundException when reading file from command line args

文件類在哪個目錄中查找文件? 我的代碼在一個單獨的項目中工作。 我在源目錄和更高目錄中都有文件project2.torrent。 我很確定它很小。 希望我不要模糊。

java.io.FileNotFoundException: project2.torrent (The system cannot find the file specified)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(FileInputStream.java:146)
    at RUBTClient.parsing(RUBTClient.java:31)
    at RUBTClient.main(RUBTClient.java:17)

文件類在哪個目錄中查找文件?

它會查看當前目錄,通常從啟動Java的位置開始

您可以通過閱讀

System.out.println(System.getProperty("user.dir"));

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

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