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