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 withFileInputStream
for this that can be useful for others: