Example usage for javax.xml.bind JAXBException printStackTrace

List of usage examples for javax.xml.bind JAXBException printStackTrace

Introduction

In this page you can find the example usage for javax.xml.bind JAXBException printStackTrace.

Prototype

public void printStackTrace(PrintWriter s) 

Source Link

Document

Prints this JAXBException and its stack trace (including the stack trace of the linkedException if it is non-null) to the PrintWriter.

Usage

From source file:org.openestate.is24.restapi.examples.RandomRealEstateExample.java

/**
 * Main function./*from  w w  w  .  j a va2 s . com*/
 *
 * @param args
 * command line arguments
 */
public static void main(String[] args) {
    try {
        final RandomRealEstateFactory factory = new RandomRealEstateFactory();
        final Charset charset = Charset.forName("UTF-8");
        for (RandomRealEstateFactory.Type type : RandomRealEstateFactory.Type.values()) {
            System.out.println("----------------------------------------");
            System.out.println("example for " + type + ":");
            RealEstate realEstate = factory.createRandomObject(type);
            ByteArrayOutputStream output = null;
            try {
                output = new ByteArrayOutputStream();
                XmlUtils.writeXml(realEstate, charset.name(), true, output);
                ByteBuffer buffer = ByteBuffer.wrap(output.toByteArray());
                String xml = charset.decode(buffer).toString();
                System.out.println(xml.trim());
            } finally {
                IOUtils.closeQuietly(output);
            }
        }
    } catch (JAXBException ex) {
        System.err.println("XML error!");
        ex.printStackTrace(System.err);
    }
}