use of org.eclipse.rdf4j.model.Graph in project opentheso by miledrousset.
the class WriteRdfFileTest method writeRio.
@Test
public void writeRio() {
FileOutputStream out = null;
try {
// a collection of several RDF statements
Graph myGraph = null;
out = new FileOutputStream("test_unesco2.rdf");
try {
RDFWriter writer = Rio.createWriter(RDFFormat.RDFXML, out);
writer.startRDF();
for (Statement st : myGraph) {
writer.handleStatement(st);
}
writer.endRDF();
} catch (RDFHandlerException e) {
// oh no, do something!
}
} catch (FileNotFoundException ex) {
Logger.getLogger(WriteRdfFileTest.class.getName()).log(Level.SEVERE, null, ex);
// oh no, do something!
} finally {
try {
out.close();
} catch (IOException ex) {
Logger.getLogger(WriteRdfFileTest.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
use of org.eclipse.rdf4j.model.Graph in project rdf4j by eclipse.
the class DAWGTestResultSetUtil method toGraph.
public static Graph toGraph(TupleQueryResult tqr) throws QueryEvaluationException {
Graph graph = new GraphImpl();
DAWGTestResultSetWriter writer = new DAWGTestResultSetWriter(new StatementCollector(graph));
try {
writer.startQueryResult(tqr.getBindingNames());
while (tqr.hasNext()) {
writer.handleSolution(tqr.next());
}
writer.endQueryResult();
} catch (TupleQueryResultHandlerException e) {
// StatementCollector, foud a bug?
throw new RuntimeException(e);
}
return graph;
}
Aggregations