相关疑难解决方法(0)

Java FileReader的问题

您好我的代码中有这个

File file = new File("words.txt");
    Scanner scanFile = new Scanner(new FileReader(file));
    ArrayList<String> words = new ArrayList<String>();

    String theWord;    
    while (scanFile.hasNext()){
        theWord = scanFile.next();
        words.add(theWord);
    }
Run Code Online (Sandbox Code Playgroud)

但出于某种原因,我得到了一个

java.io.FileNotFoundException

我将words.txt文件放在与所有.java文件相同的文件夹中

我究竟做错了什么?谢谢!

java text-files filereader

1
推荐指数
2
解决办法
2999
查看次数

标签 统计

filereader ×1

java ×1

text-files ×1