I'm trying to get the relative path for a file but without success.The absolute path is:"/Users/dev/Documents/projects/testService/src/main/resources/response.xml". After i deploy my code I'm getting java.io.FileNotFoundException:(No such file or directory).
Can you please help me? Thank you
0
The code looks like this:
try {
XMLInputFactory xif = XMLInputFactory.newFactory();
XMLStreamReader xsr = xif.createXMLStreamReader(new FileReader("src/main/resources/response.xml"));
while(xsr.hasNext()) {
xsr.next();
if (xsr.getEventType() == XMLStreamConstants.START_DOCUMENT || xsr.getEventType() == XMLStreamConstants.END_DOCUMENT ||xsr.isCharacters() == true || xsr.hasText() == true || xsr.getEventType() == XMLEvent.END_ELEMENT)
continue;
QName name = xsr.getName();
int index = name.toString().indexOf('}');
String aa = name.toString().substring(index+1);
if (xsr.isStartElement() && aa.contains("Bonitae"))
break;
}
jaxbContext = JAXBContext.newInstance(Customer.class);
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
response = unmarshaller.unmarshal(xsr, Customer.class);
}
On my local pc it's working fine. I deployed the project using a jar.