Utilisation de getResource
Bonjour,
je doit modifier un bout de code java pour pouvoir accéder à des fichiers qui seront intégré directement dans le jar de l'application.
Voici le bout de code concerné :
Code:
1 2 3 4 5 6 7 8 9
| static {
URL url = null;
try {
url = new URL("file:path/to/file/fichier.ext");
} catch (MalformedURLException e) {
//...
}
WSDL_LOCATION = url;
} |
J'ai vu qu'il fallait utiliser getResource() pour cela, j'ai donc fait :
Code:
1 2 3 4 5 6 7 8 9
| static {
URL url = null;
try {
url = java.net.URL.class.getResource("path/to/file/fichier.ext");
} catch (MalformedURLException e) {
//...
}
WSDL_LOCATION = url;
} |
Mais j'ai une erreur sur le catch :
Citation:
Unreachable catch block for MalformedURLException. This exception is never thrown from the try statement body
Quelqu'un peut m'aider ?
Merci