Java XML Parse File parse(File f)

Here you can find the source of parse(File f)

Description

parse

License

Open Source License

Declaration

public static Document parse(File f) throws SAXException, IOException 

Method Source Code


//package com.java2s;
/*/*from www  .  jav a  2s . c o  m*/
 * dbXML - Native XML Database
 * Copyright (c) 1999-2006 The dbXML Group, L.L.C.
 *
 * Permission is hereby granted, free of charge, to any person obtaining
 * a copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * The above copyright notice and this permission notice shall be included
 * in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 * $Id: DOMHelper.java,v 1.5 2006/02/02 19:04:15 bradford Exp $
 */

import java.io.File;
import java.io.IOException;
import java.io.InputStream;

import javax.xml.parsers.DocumentBuilder;

import org.w3c.dom.Document;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;

public class Main {
    private static ThreadLocal db;

    public static Document parse(InputSource is) throws SAXException, IOException {
        return getDocumentBuilder().parse(is);
    }

    public static Document parse(File f) throws SAXException, IOException {
        return getDocumentBuilder().parse(f);
    }

    public static Document parse(InputStream is) throws SAXException, IOException {
        return getDocumentBuilder().parse(is);
    }

    public static Document parse(InputStream is, String systemId) throws SAXException, IOException {
        return getDocumentBuilder().parse(is, systemId);
    }

    private static DocumentBuilder getDocumentBuilder() {
        return (DocumentBuilder) db.get();
    }
}

Related

  1. parse(File f)
  2. parse(File f)
  3. parse(File f, boolean validation)
  4. parse(File f, DefaultHandler dh)
  5. parse(File file)
  6. parse(File file)