Search This Blog

Java: open resource file using relative path

File dictionaryFile = new File(getClass().getResource("resources/dictionary.txt").toURI().getPath());
System.out.println("File Length:" + f.length());
or
getClass().getResourceAsStream("resources/dictionary.txt");

No comments:

Post a Comment