Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import javax.xml.stream.XMLEventReader;

import javax.xml.stream.XMLStreamException;

import javax.xml.stream.events.XMLEvent;

public class Main {
    /**
     * Advances the event stream until it encounters a start or end tag, but
     * does not actaully read the event.
     * 
     * @param reader The reader to peek.
     * @return The next StartElement or EndElement event, retrieved using
     *         <code>peek()</code>, or <code>null</code> if the end of the
     *         stream was encountered before any tag event.
     * @throws XMLStreamException If an error occurs reading the stream.
     */
    public static final XMLEvent nextTag(XMLEventReader reader) throws XMLStreamException {

        while (reader.hasNext()) {

            XMLEvent nextEvent = reader.peek();
            if (nextEvent.isStartElement() || nextEvent.isEndElement()) {

                return nextEvent;

            } else {

                // eat the event.
                reader.nextEvent();

            }

        }

        return null;

    }
}