intellij-idea系统找不到指定的文件,

有人能帮我吗? 我是编程的新手,我决定尝试从eclipse尝试IDEA,我遇到了一个问题,我已经从eclipse导入了一个项目,但在IDEA中,我不能像我在eclipse中那样尊重我的res文件夹不能使用res / image.png我只能做c:\ ect。 有谁知道为什么? 我已将res文件夹设置为资源根目录。

对于像这样的项目结构:

 project | | -> src | | | | -> directory | | | | | | -> MyClass.java | | | | | | -> file.txt 

使用以下代码读取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(); } } }