can someone help me? i\'m pretty new to programming, I decided to give IDEA a try comming from eclipse and I have run into a problem I have imported a project from eclipse that
For a project structure like this:
project
|
| -> src
| |
| | -> directory
| | |
| | | -> MyClass.java
| | |
| | | -> file.txt
Use the below code to read the file in MyClass.java
import java.io.*;
class MyClass {
public static void main(String... args) {
try {
BufferedReader br = new BufferedReader(new FileReader("src/directory/file.txt"));
// read your file
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
}