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