Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;

import javax.xml.transform.TransformerFactory;

public class Main {
    private static final TransformerFactory TRANSFORMER_FACTORY = TransformerFactory.newInstance();

    /**
     * @return a transformer that indents entries by 4 characters (never null)
     */
    public static Transformer createIndentingTransformer() {
        Transformer transformer;
        try {
            TRANSFORMER_FACTORY.setAttribute("indent-number", 4);
            transformer = TRANSFORMER_FACTORY.newTransformer();
        } catch (final Exception e) {
            throw new IllegalStateException(e);
        }
        transformer.setOutputProperty(OutputKeys.INDENT, "yes");
        transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
        return transformer;
    }
}