简体   繁体   中英

JAXB UnmarshalException - Filename containing #

SCENARIO
I am using JAXB 2.0, and I had a process that receive xml files from a webservice that need to be unmarshalled. Names are provided by webservice and with format:

ESA08021701#99152015AA00024175#20150612#20150618125838_NOTIF_250073.xml

PROBLEM
When I try to unmarshall this files:

File file = // get my file from a list
unmarshaller.unmarshal(file);

I get this UnmarshalException

javax.xml.bind.UnmarshalException - with linked exception: [java.io. FileNotFoundException: ESA08021701 (The system cannot find the file specified.)] at javax.xml.bind.UnmarshalException.(UnmarshalException.java:56)

I've notticed the filename in Exception is not complet ESA08021701 , but debugging I can see filename is correct and File exists...

QUESTION
Is this a bug? AFAIK # is not a special character for filenames? How can I process this files?

After researching in documentation and forums, I guess this still is a JaxB problem, but finally I found a workaround with FileInputStream for this that can be useful for others:

File file = // get my file from a list
Object unmarshalled = unmarshaller.unmarshal(new FileInputStream(myFile));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM