Reading files with Intellij idea IDE

Just move the file directly to the project folder which calls Java (and something under the blue-blurred stripe you made :P).

If that doesn't help, then move the test123.txt file to FirstJavaProgram directory.

You can also change filename to one of these:

  1. src/test123.txt

  2. FirstJavaProgram/src/test123.txt

I am not sure which one will be fine in your case.


Use the full path of the file instead.

Right click on your file in your project, select "Copy Path", and paste that in to the path of your file.

EDIT: You could also use a relative path for your file. If your file is located in resources/, then you could use the form ./resources/yourfile.txt.

├── resources
│   └── test123.txt
└── src
    ├── MainClass.java

Yesterday I met the same trouble as you.

change the setting of IDEA. run->Edit Configurations -> (select your Application at left window.then set the input content named "Working directory" at right window)

click here to see the image