Here you can find the source of parseNumber(XMLEventReader stream)
private static int parseNumber(XMLEventReader stream) throws XMLStreamException
//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()); } }