0
我正在使用以下代碼使用JAXB創建XML,但創建XML時不包括XML標頭。JAXB - 忽略XML標頭
OutputStream file = new FileOutputStream("E:\\file.xml");
JAXBContext jaxbContext = JAXBContext.newInstance(F6207.class);
javax.xml.bind.Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
jaxbMarshaller.setProperty(javax.xml.bind.Marshaller.JAXB_ENCODING, "UTF-8");
jaxbMarshaller.setProperty(javax.xml.bind.Marshaller.JAXB_FRAGMENT, Boolean.FALSE);
jaxbMarshaller.setProperty(javax.xml.bind.Marshaller.JAXB_FORMATTED_OUTPUT, true);
jaxbMarshaller.marshal(f6207, file);
如何將下面的標題放到我的XML文件中?
<?xml version="1.0" encoding="UTF-8"?>
這爲我工作。非常感謝! – KhadBr
@KhadBr歡迎你的朋友;) –