Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import java.io.StringReader;

import javax.xml.parsers.DocumentBuilder;

import org.w3c.dom.Document;

import org.xml.sax.InputSource;

public class Main {
    static public Exception exception = null;
    static private DocumentBuilder parser = null;

    public static synchronized Document riskyParse(String text) throws Exception {
        InputSource is = new InputSource(new StringReader(text));
        return parser.parse(is);
    }

    static public Document parse(String text) {
        Document document = null;
        exception = null;
        try {
            document = riskyParse(text);
        } catch (Exception e) {
            exception = e;
        }
        return document;
    }
}