和windows是一样的,放在classpath.

解决方案 »

  1.   

    应该是当前的工作目录,用System.getPropety("user.dir")查一下,打出这个工作目录就行了。
      

  2.   

    MyFileReader mfr = new MyFileReader();
    String path = mfr.getClass().getResource("hello.txt").getPath();
    System.out.println(path);结果可能就是 /dir1/dir2/.../dirn/hello.txt
    也可能是  file://dir1/dir2/.../dirn/hello.txt
    你自己打一下就知道了。你的MyFileReader.class 必须要和 hello.txt在同一目录下。