我在一个静态类调用的方法下面的代码是在一个罐子里存档:FileNotFoundException。工作并不能同时工作?
1 System.out.println(Methods.class.getResource("tagdict.txt"));
2 URL test=Methods.class.getResource("tagdict.txt");
3 System.out.println(test.getPath());
4 TagDictionary dict = new POSDictionary(test.getPath());
第一的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,即使该文件已被发现在jar中。
这将有助于POSDictionary构造函数的代码,因为引发异常。 – Viruzzo 2012-01-17 09:47:48