Java XML Parse File parse(String fileName)

Here you can find the source of parse(String fileName)

Description

parse

License

Open Source License

Declaration

public static XMLStreamReader parse(String fileName) throws IOException, XMLStreamException 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import java.io.*;
import java.net.URL;

public class Main {
    /**/*w w w  .j av  a 2s .  c o  m*/
     * StAX parse XML resource into XMLStreamReader
     * @return XMLStreamReader
     * @throws IOException
     * @throws XMLStreamException
     */
    public static XMLStreamReader parse(URL url) throws IOException, XMLStreamException {
        InputStream input = url.openStream();
        XMLInputFactory xif = XMLInputFactory.newInstance();
        XMLStreamReader xmlStreamReader = xif.createXMLStreamReader(input);

        return xmlStreamReader;
    }

    public static XMLStreamReader parse(File xmlFile) throws IOException, XMLStreamException {
        FileReader input = new FileReader(xmlFile);
        XMLInputFactory xif = XMLInputFactory.newInstance();
        XMLStreamReader xmlStreamReader = xif.createXMLStreamReader(input);

        return xmlStreamReader;
    }

    public static XMLStreamReader parse(String fileName) throws IOException, XMLStreamException {
        FileInputStream input = new FileInputStream(fileName);
        XMLInputFactory xif = XMLInputFactory.newInstance();
        XMLStreamReader xmlStreamReader = xif.createXMLStreamReader(input);

        return xmlStreamReader;
    }
}

Related

  1. parse(File file)
  2. parse(File file)
  3. parse(File iFile)
  4. parse(File input)
  5. parse(File xml, ErrorHandler errorHandler)
  6. parse(String fileName)
  7. parse(String filename)
  8. parse(String filename)
  9. parse(String fileName)