简体   繁体   English

找不到Eclipse档案错误-尽管档案总管中显示档案

[英]Eclipse file not found error - Despite file showing up in the package explorer

I am getting a file not found error in eclipse, i am trying to read a file called input.txt, and the file is present in the project folder alongside the class. 我在Eclipse中遇到文件未找到错误,我正在尝试读取一个名为input.txt的文件,并且该文件与类一起存在于项目文件夹中。

I have refreshed the folder in eclipse itself and it is showing up on the project explorer on the left hand side, but when i try to run the program i get the following: 我已经刷新了eclipse本身中的文件夹,它显示在左侧的项目浏览器中,但是当我尝试运行该程序时,得到以下信息:

Exception in thread "main" java.io.FileNotFoundException: input.txt (The system cannot find the file specified)
at java.io.FileInputStream.open0(Native Method)
at java.io.FileInputStream.open(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileReader.<init>(Unknown Source)
at CourseWorkClass.main(CourseWorkClass.java:14)

I should note that the code was working fine earlier on a different computer, but I since copied the code into a new project and now it will not work. 我应该注意,该代码之前在另一台计算机上运行良好,但由于将代码复制到新项目中,因此现在无法正常工作。

Eclipse picks the file from the top folder if the file path is relative. 如果文件路径是相对的,则Eclipse从顶部文件夹中选择文件。 So try moving the file to project's top folder 因此,请尝试将文件移动到项目的顶部文件夹

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM