Android XML InputStream Parse newPullParser(InputStream input)

Here you can find the source of newPullParser(InputStream input)

Description

Create the factory if necessary and return a new pull parser.

Parameter

Parameter Description
input the input stream to be parsed.

Exception

Parameter Description
XmlPullParserException if unable to create a parser from the stream

Return

a newly created parser

Declaration

public static XmlPullParser newPullParser(InputStream input)
        throws XmlPullParserException 

Method Source Code

//package com.java2s;
import java.io.InputStream;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlPullParserFactory;

public class Main {
    private static XmlPullParserFactory sFactory;

    /**/* www  .j ava  2s  .c  o  m*/
     * Create the factory if necessary and return a new pull parser. 
     * 
     * @param input the input stream to be parsed. 
     * @return a newly created parser
     * @throws XmlPullParserException if unable to create a parser from the stream
     */
    public static XmlPullParser newPullParser(InputStream input)
            throws XmlPullParserException {

        if (sFactory == null) {
            sFactory = XmlPullParserFactory.newInstance();
        }

        final XmlPullParser parser = sFactory.newPullParser();
        parser.setInput(input, null);
        return parser;
    }
}

Related

  1. readSetXml(InputStream in)
  2. InputStreamToDocument(InputStream istr)
  3. LoadXml(InputStream stream)
  4. getDocument(InputStream is)
  5. getPullParser(InputStream in, String encoding)
  6. obtainEncodingStringFromInputStream(InputStream bis)
  7. parse(InputStream in, ContentHandler handler)
  8. parse(InputStream is)
  9. parse(InputStream is)