Java maven project trying to read file from resources -


i trying read xml file resources folder of maven web project, instead of trying read source files, tries read jar file generated in web-inf folder, throws not found exception. how can address issue? thanks

classloader classloader = getclass().getclassloader(); file file = new file(classloader.getresource("folder_x/file.xml").getfile()); 

under resources, have folder_x , in there have file.xml

if run:

classloader classloader = getclass().getclassloader(); file file = new file(classloader.getresource("/folder_x/file.xml").getfile()); 

i null pointer exception.

pom.xml:

<?xml version="1.0" encoding="utf-8"?>  <project xmlns="maven.apache.org/pom/4.0.0"; xmlns:xsi="w3.org/2001/xmlschema-instance"; xsi:schemalocation="maven.apache.org/pom/4.0.0 maven.apache.org/xsd/maven-4.0.0.xsd">;    <modelversion>4.0.0</modelversion>    <groupid>xmltest</groupid>   <artifactid>xmltest</artifactid>    <version>1.0-snapshot</version>  </project> 


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -