Код: Выделить всё
public String toString(JAXBElement element) {
StringWriter sw = new StringWriter();
marshal(element, sw);
return sw.toString();
}
public void marshal(JAXBElement element, final Writer writer, MarshallerProperty... msProps) {
try {
**createMarshaller(msProps).marshal(element, writer);**
} catch (JAXBException ex) {
throw new JaxbSystemException(
"ConsumptionJaxbHelper failed to marshal " + element.getClass().getTypeName(), ex);
}
}
private Marshaller createMarshaller(MarshallerProperty... msProps) {
try {
Marshaller m = jaxbContext.createMarshaller();
m.setProperty(Marshaller.JAXB_ENCODING, "UTF-8");
m.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.FALSE);
m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
for(MarshallerProperty msProp : msProps) {
m.setProperty(msProp.getPropertyName(), msProp.getPropertyValue());
}
return m;
} catch (JAXBException ex) {
throw new JaxbSystemException("ConsumptionJaxbHelper failed to create Marchaller.", ex);
}
}
Код: Выделить всё
java.lang.OutOfMemoryError: null
at java.lang.AbstractStringBuilder.hugeCapacity(AbstractStringBuilder.java:214) ~[?:?]
at java.lang.AbstractStringBuilder.newCapacity(AbstractStringBuilder.java:206) ~[?:?]
at java.lang.AbstractStringBuilder.ensureCapacityInternal(AbstractStringBuilder.java:173) ~[?:?]
at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:686) ~[?:?]
at java.lang.StringBuffer.append(StringBuffer.java:414) ~[?:?]
at java.io.StringWriter.write(StringWriter.java:99) ~[?:?]
at java.io.BufferedWriter.flushBuffer(BufferedWriter.java:120) ~[?:?]
at java.io.BufferedWriter.flush(BufferedWriter.java:256) ~[?:?]
at com.sun.xml.bind.v2.runtime.MarshallerImpl.cleanUp(MarshallerImpl.java:347) ~[jaxb-runtime-2.4.0-b180830.0438.jar:2.4.0-b180830.0438]
at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:340) ~[jaxb-runtime-2.4.0-b180830.0438.jar:2.4.0-b180830.0438]
at com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:256) ~[jaxb-runtime-2.4.0-b180830.0438.jar:2.4.0-b180830.0438]
at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:101) ~[jakarta.xml.bind-api-2.3.2.jar:2.3.2]
Подробнее здесь: https://stackoverflow.com/questions/792 ... large-file