Java XML Parse Stream parseNumber(XMLEventReader stream)

Here you can find the source of parseNumber(XMLEventReader stream)

Description

parse Number

License

Apache License

Declaration

private static int parseNumber(XMLEventReader stream)
            throws XMLStreamException 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import javax.xml.stream.XMLEventReader;

import javax.xml.stream.XMLStreamException;

public class Main {
    private static int parseNumber(XMLEventReader stream)
            throws XMLStreamException {
        StringBuilder sb = new StringBuilder(5);
        while (stream.peek().isCharacters()) {
            sb.append(stream.nextEvent().asCharacters().getData());
        }//w  w w.  j av  a 2s .  co m
        if (!stream.nextEvent().isEndElement()) {
            throw new RuntimeException(
                    "Did not end up with end tag while parsing number.");
        }
        return Integer.parseInt(sb.toString());
    }
}

Related

  1. parseInputStream(InputStream in, boolean namespaces, boolean validating)
  2. parseInputStream(InputStream is)
  3. parseMulXML( InputStream is, String[] tagNames)
  4. parseNamespace(XMLStreamReader reader)
  5. parseNoContent(final XMLStreamReader reader)
  6. parser(InputStream inputStream)
  7. parseStream(InputStream stream, boolean validate, boolean expandEntityRefs)
  8. parseStreamToXML(InputStream in)
  9. parseText(XMLStreamReader parser)