KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
i have a maven project structure where i have src/main/resources/json/test.xml file present i am trying to read this using the following code but not able to read it.I ma getting cannot find the file specified.I have to pass a file object to unmarshal function ,how can i do this using other apporach File file = new File("json\\test.xml"); JAXBContext jaxbContext = JAXBContext.newInstance(ServiceApi.class); Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); ServiceApi customer = (ServiceApi) jaxbUnmarshaller.unmarshal(file); System.out.println(customer.getService().size()); The exception is javax.xml.bind.UnmarshalException - with linked exception: [java.io.FileNotFoundException: C:\Users\jayesh_shah\Downloads\dbt-dataformstub\json\test.xml (The system cannot find the path specified)] at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:202) at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:173) at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:137) at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:142) at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:151) at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:169) at com.ge.stub.api.jaxb.JAXBExample.main(JAXBExample.java:17) Caused by: java.io.FileNotFoundException: C:\Users\jayesh_shah\Downloads\dbt-dataformstub\json\test.xml (The system cannot find the path specified) at java.io.FileInputStream.open(Native Method) at java.io.FileInputStream.<init>(FileInputStream.java:120) at java.io.FileInputStream.<init>(FileInputStream.java:79) at sun.net.www.protocol.file.FileURLConnection.connect(F
Tags (comma-separated)
Save Edits
Cancel