Lecture d'une ressource de type xml à l'intérieur d'un jar
Bonjour,
J'ai un problème de lecture de fichier, et je ne comprends pas pourquoi.
Je tiens à signaler que le JAR contient bien le fichier voulu >>
$ jar tvf target/***-0.1.0-SNAPSHOT.jar
...
26272057 Wed Feb 10 12:33:28 CET 2010 data/fic.xml
Je suis sous Eclipse/Mac OSX/JRE 1.5
Code:
1 2 3 4 5 6 7 8 9
|
...
URL url = this.getClass().getResource("/data/fic.xml");
File f = new File(url.getFile());
//System.out.println(f.getPath());
FileInputStream fis = new FileInputStream(f);
byte[] ba = new byte[(int)f.length()];
fis.read(ba);
... |
voici l'error retourné :/
exception occurred ==>java.io.FileNotFoundException: file:/Users/***/Documents/workspace/***/target/***-0.1.0-SNAPSHOT.jar!/data/fic.xml (No such file or directory)
Exception in thread "main" java.lang.NullPointerException
Si quelqun a une idée ça serait formidable :)