use of org.eclipse.rdf4j.rio.rdfxml.RDFXMLWriter in project rdf4j by eclipse.
the class RDFXMLHandlingTest method writeRDFXML.
/**
* Helper method to write the given model to RDFXML and return an InputStream containing the results.
*
* @param statements
* @return An {@link InputStream} containing the results.
* @throws RDFHandlerException
*/
private InputStream writeRDFXML(Model statements) throws RDFHandlerException {
StringWriter writer = new StringWriter();
RDFWriter rdfxmlWriter = new RDFXMLWriter(writer);
rdfxmlWriter.startRDF();
for (Statement nextStatement : statements) {
rdfxmlWriter.handleStatement(nextStatement);
}
rdfxmlWriter.endRDF();
return new ByteArrayInputStream(writer.toString().getBytes(Charset.forName("UTF-8")));
}
Aggregations