use of org.eclipse.rdf4j.rio.RDFWriter 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);
}
}
}
Aggregations