java.io.FileNotFoundException: the system cannot find the file specified

前端 未结 8 1421
Happy的楠姐
Happy的楠姐 2020-11-22 15:27

I have a file named \"word.txt\".

It is in the same directory as my java file.

But when I try to access it in the following code th

相关标签:
8条回答
  • 2020-11-22 16:15

    I was reading path from a properties file and didn't mention there was a space in the end. Make sure you don't have one.

    0 讨论(0)
  • 2020-11-22 16:15

    i think it always boils to the classpath. having said that if you run from the same folder where your .class is then change Scanner input = new Scanner(new File("word.txt")); to Scanner input = new Scanner(new File("./word.txt")); that should work

    0 讨论(0)
提交回复
热议问题