1
我将创建一个类,它应该解开非常大的xml文件。Java JAXB多线程解组
我实现了一般解组:
public XMLProcessor(XMLFile file) throws JAXBException, IOException, SAXException {
JAXBContext jc = JAXBContext.newInstance(Customers.class);
Unmarshaller unmarshaller = jc.createUnmarshaller();
File xml = new File(file.getFile().getOriginalFilename());
file.getFile().transferTo(xml);
this.customers = (Customers) unmarshaller.unmarshal(xml);
}
它工作正常,但花了一分多钟的过程1万个客户XML。
我可以通过创建多个线程并同时解组XML文件的几个部分来提高性能吗?
我应该如何将XML文件分成几部分?
您能告诉我一些我的案例的示例代码吗?
我放弃了使用SAX的想法。相反,我生成了一些适当的JAXB注释类,而解组器的速度令人印象深刻。 1.6GB在没有任何多线程的情况下在40秒内得到解组。这对我的情况来说已经足够了 – cgicgi