Relative to absolute path in java
问题 I have have a file that I want to use in my project which is in the resources package src.res Following what was stated in this answer, I believe that my code is valid. File fil = new File("/res/t2.nii"); // Prints C:\\res\\t2.nii System.out.println(fil.getAbsolutePath()); The problem is that I that file is in my projects file not there, so I get an Exception. How am I suppose to properly convert from relative path to absolute? 回答1: Since you are using a Java package, you must to use a class