Or use the Resource's InputStream directly, using the absolute CLASSPATH path (starting with a slash / ):
getClass().getResourceAsStream("/com/path/to/file.txt");
getClass().getResourceAsStream("/com/path/to/file.txt");
Or the relative CLASSPATH path (when the class you are writing is in the same Java package as the resource file itself, i.e. com.path.to ):
getClass().getResourceAsStream("file.txt");
getClass().getResourceAsStream("file.txt");
Jiri Patera Dec 05 '10 at 17:03 2010-12-05 17:03
source share