Netbeans 12.6不打开Mac上的TXT文件
我正在尝试使用 Java 在 NetBeans 12.6 中打开 txt 文件。我将txt文件放在主项目文件中。当我尝试使用文件和扫描程序方法打开文件时,我不断收到“未报告的异常 FileNotFoundException”错误。 12.6 有一个新的地方可以放置 txt 文件吗?我使用的是 Mac,所以我不知道这是否会增加问题。当我使用 NetBeans 8 时,它曾经工作正常。这是我的代码:
File bookList = new File("BookPrices.txt");//File to be opened
Scanner inputFile = new Scanner(bookList);//Scanner for the file of books
I am trying to open a txt file in NetBeans 12.6 using Java. I placed the txt file in the main project file. When I try to open the file using the File and Scanner method I keep getting the "Unreported exception FileNotFoundException" error. Is there a new place you're supposed to put the txt file with 12.6? I am using a mac so I don't know if that is adding to the problem. It used to work fine when I was using NetBeans 8. Here is my code:
File bookList = new File("BookPrices.txt");//File to be opened
Scanner inputFile = new Scanner(bookList);//Scanner for the file of books
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我弄清楚了!我需要尝试/捕捉
I figured it out! I needed to put it in a Try/Catch