У меня есть следующий код в статическом классе с именем Methods, который заархивирован в банке:
System.out.println(Methods.class.getResource("tagdict.txt")); // 1
URL test = Methods.class.getResource("tagdict.txt"); // 2
System.out.println(test.getPath()); // 3
TagDictionary dict = new POSDictionary(test.getPath()); // 4
Первый System.out
(1) говорит:
rsrc:de/fhg/scai/bio/harsha/classificationworkflow/tagdict.txt
секунда System.out
(2) говорит:
de/fhg/scai/bio/harsha/classificationworkflow/tagdict.txt
Строка 4 выбрасывает
java.io.FileNotFoundException: de/fhg/scai/bio/harsha/classificationworkflow/tagdict.txt (No such file or directory)
Файл tagdict.txt
помещается в тот же пакет, что и Method.class
, чтоde/fhg/scai/bio/harsha/classificationworkflow
.
Я не понимаю, почему в строке 4 выбрасывается FileNotFoundException
, хотя файл был найден уже внутри банки.