org.jvnet.jaxbcommons.util.FormatUtils Maven / Gradle / Ivy
package org.jvnet.jaxbcommons.util;
import java.io.StringWriter;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
public class FormatUtils {
private FormatUtils() {
}
public static String format(JAXBContext context, Object object) throws JAXBException {
final Marshaller marshaller = context.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
final StringWriter sw = new StringWriter();
marshaller.marshal(object, sw);
return sw.toString();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy