List of usage examples for org.springframework.util.xml StaxUtils createStaxResult
public static Result createStaxResult(XMLEventWriter eventWriter)
From source file:org.emonocot.job.io.StaxEventItemWriter.java
/** * Write the value objects and flush them to the file. * * @param items//from ww w . j a v a 2 s .c o m * the value object * @throws IOException * if there is a problem writing to the resource */ public final void write(final List<? extends T> items) throws IOException { currentRecordCount += items.size(); for (Object object : items) { Assert.state(marshaller.supports(object.getClass()), "Marshaller must support the class of the marshalled object"); try { marshaller.marshal(object, StaxUtils.createStaxResult(eventWriter)); } catch (XmlMappingException e) { throw new IOException(e.getMessage()); } catch (XMLStreamException e) { throw new IOException(e.getMessage()); } } try { eventWriter.flush(); } catch (XMLStreamException e) { throw new WriteFailedException("Failed to flush the events", e); } }