Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.text.ParseException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

import org.w3c.dom.Document;

public class Main {
    /**
     * Create a new blank XML document.
     * 
     * @return The new blank XML document.
     * 
     * @throws IOException
     *             If there is an error creating the XML document.
     * @throws ParseException
     */
    public static Document newDocument() throws ParseException {

        final DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
        DocumentBuilder builder;
        try {
            builder = builderFactory.newDocumentBuilder();
        } catch (final ParserConfigurationException e) {
            final ParseException thrown = new ParseException(e.getMessage(), 0);
            throw thrown;
        }
        return builder.newDocument();
    }
}