use of ezvcard.io.StreamReader in project ez-vcard by mangstadt.
the class XCardDocumentTest method readXml.
private static VCardAsserter readXml(String xml) throws SAXException {
XCardDocument xcard = new XCardDocument(xml);
StreamReader reader = xcard.reader();
return new VCardAsserter(reader);
}
use of ezvcard.io.StreamReader in project ez-vcard by mangstadt.
the class XCardDocumentTest method readFile.
private static VCardAsserter readFile(String file) throws SAXException, IOException {
XCardDocument document = new XCardDocument(XCardDocumentTest.class.getResourceAsStream(file));
StreamReader reader = document.reader();
return new VCardAsserter(reader);
}
use of ezvcard.io.StreamReader in project ez-vcard by mangstadt.
the class ChainingParser method all.
/**
* Reads all vCards from the stream.
* @return the parsed vCards
* @throws IOException if there's an I/O problem
*/
public List<VCard> all() throws IOException {
StreamReader reader = constructReader();
if (index != null) {
reader.setScribeIndex(index);
}
try {
List<VCard> vcards = new ArrayList<VCard>();
VCard vcard;
while ((vcard = reader.readNext()) != null) {
if (warnings != null) {
warnings.add(reader.getWarnings());
}
vcards.add(vcard);
}
return vcards;
} finally {
if (closeWhenDone()) {
reader.close();
}
}
}
Aggregations