在哪里可以把我想要阅读的txt文件放在Java中? [英] Where do I put the txt file that I want to read in Java?

查看:119
本文介绍了在哪里可以把我想要阅读的txt文件放在Java中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我正在使用Java在Eclipse中构建一个应用程序,并且我希望这个应用程序从一个txt文件中读取,那么我应该把txt文件放到这个包中,以便不必指定它的路径(这样我可以只要说file.txt)。我认为它应该在src文件夹中,但它不工作。

解决方案

右键单击项目文件夹,然后单击新 - >文件。该文件将在Project文件夹中,而不在源文件夹中。


If I am building an application in Eclipse using Java, and I want this application to read from a txt file, where should I put the txt file in the package in order to not have to specify its path (so that I can just say "file.txt"). I thought that it was supposed to go in the src folder, but it's not working.

解决方案

Right click the project folder and click New -> file. The file will be in the Project folder and not in the source folder.

这篇关于在哪里可以把我想要阅读的txt文件放在Java中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆