我有問題在jar文件中使用JWNL
wordnet。RandomAccessFile讀取Jar文件中的文件
JWNL
使用RandomAccessFile讀取wordnet字典文件。爲了創建Jar文件,將wordnet字典文件放在resources/wordnet文件夾中。由於資源位於我的構建路徑中,因此運行我在Eclipse中創建的應用程序時沒有問題。然而,當我使用其他應用程序運行所創建的jar文件,我得到以下錯誤:
java.io.FileNotFoundException: resources/wordnet/data.noun (No such file or directory)
從下面的代碼:
RandomAccess _file = new RandomAccessFile(path, _permissions);
我用下面的代碼來檢查當前的工作目錄:
URL location = PrincetonRandomAccessDictionaryFile.class.getProtectionDomain().getCodeSource().getLocation();
System.out.println(location.getFile());
看起來既情況具有相同的位置:/project/bin/
我應該如何解決這個問題?謝謝