Search in sources :

Example 1 with TriGParser

use of org.openrdf.rio.trig.TriGParser in project eol-globi-data by jhpoelen.

the class LinkerTrustyNanoPubsTest method toTrigString.

private String toTrigString(InputStream rdfIn) throws IOException, RDFParseException, RDFHandlerException {
    TriGParser rdfParser = new TriGParser();
    Model model = new LinkedHashModel();
    rdfParser.setRDFHandler(new StatementCollector(model));
    rdfParser.parse(rdfIn, "http://example.com");
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    Rio.write(model, out, RDFFormat.TRIG);
    return new String(out.toByteArray(), "UTF-8");
}
Also used : TriGParser(org.openrdf.rio.trig.TriGParser) StatementCollector(org.openrdf.rio.helpers.StatementCollector) Model(org.openrdf.model.Model) LinkedHashModel(org.openrdf.model.impl.LinkedHashModel) LinkedHashModel(org.openrdf.model.impl.LinkedHashModel) ByteArrayOutputStream(java.io.ByteArrayOutputStream)

Aggregations

ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 Model (org.openrdf.model.Model)1 LinkedHashModel (org.openrdf.model.impl.LinkedHashModel)1 StatementCollector (org.openrdf.rio.helpers.StatementCollector)1 TriGParser (org.openrdf.rio.trig.TriGParser)1