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