我試圖從.jar(由builder.xml製作)加載.xml文件,但得到一個異常。從我的螞蟻的build.xml從.jar加載xml
代碼:
try {
xml = new File(this.getClass().getResource("/TaskData.xml").getFile());
} catch (Exception e) {
e.printStackTrace();
例外,我得到了:
java.io.FileNotFoundException: C:\Users\agent_000\Desktop\....file:\C:\Users\agent_000\Desktop\%d1%85%d1%83\build\sample.jar!\TaskData.xml (
爲什麼不能找到我的課
代碼一個.xml文件?
在此先感謝!
是該文件實際上是在罐子? (用winrar或其他方式打開它) –
@flkes根據mybuild.xml(這是ant文件)sample.jar創建並且是,在此.jar中的TaskData.xml。 –
@ flkes nope,同樣的例外。也許在build.xml中有問題? –