简体   繁体   English

JAXB UnmarshalException - 包含#的文件名

[英]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. 我正在使用JAXB 2.0,我有一个进程从Web服务接收需要解组的xml文件。 Names are provided by webservice and with format: 名称由webservice提供,格式如下:

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 我得到这个UnmarshalException

javax.xml.bind.UnmarshalException - with linked exception: [java.io. javax.xml.bind.UnmarshalException - 包含链接异常:[java.io. FileNotFoundException: ESA08021701 (The system cannot find the file specified.)] at javax.xml.bind.UnmarshalException.(UnmarshalException.java:56) FileNotFoundException:ESA08021701 (系统找不到指定的文件。)]在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... 我已经注意到Exception的文件名不是complet ESA08021701 ,但调试我可以看到文件名是正确的并且File存在...

QUESTION
Is this a bug? 这是一个错误吗? AFAIK # is not a special character for filenames? AFAIK #不是文件名的特殊字符? 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: 在研究文档和论坛后,我想这仍然是一个JaxB问题,但最后我找到了一个FileInputStream的解决方法,这对其他人有用:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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