public Object parseAndClose(Reader reader, Type dataType) throws IOException { try { // Initialize the parser XmlPullParser parser = Xml.createParser(); parser.setInput(reader); return readObject(parser, dataType); } catch (XmlPullParserException e) { IOException exception = new IOException(); exception.initCause(e); throw exception; } finally { reader.close(); } } }
public Object parseAndClose(InputStream in, Charset charset, Type dataType) throws IOException { try { // Initialize the parser XmlPullParser parser = Xml.createParser(); parser.setInput(in, charset.name()); return readObject(parser, dataType); } catch (XmlPullParserException e) { IOException exception = new IOException(); exception.initCause(e); throw exception; } finally { in.close(); } }