Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
// under the terms of the GNU General Public License as published by the

import org.w3c.dom.*;
import java.io.*;
import javax.xml.parsers.*;

public class Main {
    public static Document OpenDom(String sfilepath) {
        Document newdoc = null;
        try {
            newdoc = getDocumentBuilder().parse(new File(sfilepath));
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        return newdoc;
    }

    static DocumentBuilder getDocumentBuilder() {
        DocumentBuilder documentBuilder = null;
        try {
            DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
            documentBuilder = documentBuilderFactory.newDocumentBuilder();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        return documentBuilder;
    }
}