Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.io.File;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;

import org.w3c.dom.Document;

public class Main {
    /**
     * Carica il DOM a partire da un file contenente un documento XML
     * 
     * @throws Exception
     */
    public static Document caricaDOMDocument(File fileXML) throws Exception {
        DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
        Document domDocument = builder.parse(fileXML);
        if (domDocument == null) {
            throw new Exception("Errore in lettura del Document del file XML di configurazione");
        }
        return domDocument;
    }
}