Class FormattedOutputStreamRecord

All Implemented Interfaces:
AbstractMarshalRecord<CoreAbstractSession,CoreField,XMLMarshaller,NamespaceResolver>, MarshalRecord<CoreAbstractSession,CoreField,XMLMarshaller,NamespaceResolver>, XMLRecord<CoreAbstractSession>

public class FormattedOutputStreamRecord extends OutputStreamRecord

Use this type of MarshalRecord when the marshal target is an OutputStream and the XML should be formatted with carriage returns and indenting. This type is only used if the encoding of the OutputStream is UTF-8

XMLContext xmlContext = new XMLContext("session-name");
XMLMarshaller xmlMarshaller = xmlContext.createMarshaller();
FormattedOutputStreamRecord record = new FormattedOutputStreamRecord();
record.setOutputStream(myOutputStream);
xmlMarshaller.marshal(myObject, record);

If the marshal(OutputStream) and setFormattedOutput(true) method is called on XMLMarshaller and the encoding is UTF-8, then the OutputStream is automatically wrapped in a FormattedOutputStreamRecord.

XMLContext xmlContext = new XMLContext("session-name");
XMLMarshaller xmlMarshaller = xmlContext.createMarshaller();
xmlMarshaller xmlMarshaller.setFormattedOutput(true);
xmlMarshaller.marshal(myObject, myOutputStream);

See Also: