I am a long time eclipse user and I have started to play around with IntelliJ IDEA.
So from my understanding, a project in IntelliJ is the same as the Eclipse workspace. Additionally, a module in IntelliJ is the equivalent of a project in Eclipse.
I created a project in IntelliJ, but I’m still not sure why there is a src
folder in it if it is supposed to be a workspace.
Afterwards, I created a module in the project and a class inside the src
directory of the new module with this code:
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
public class MainClass {
public static void main(String[] args) throws FileNotFoundException {
System.out.println("Hello World!");
Scanner input = new Scanner(new File ("test123.txt"));
String answer = input.nextLine();
System.out.println(answer);
}
}
The problem is that I get an error trying to read the file. I tried putting the .txt file inside my src file which is located inside the module and outside the src
directory but inside the module. But in both cases the file is not found. Yes the code works, I tried it on Eclipse and it works fine. The file name is spelled correctly as well.
Here is a picture of my project/workspace if it is helpful:
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…