I create some RDF file wih JENA library: Model model = ModelFactory.createDefaultModel();
...
now how I can I convert this to string ?
thx
Try something like this:
String syntax = "RDF/XML-ABBREV"; // also try "N-TRIPLE" and "TURTLE"
StringWriter out = new StringWriter();
model.write(out, syntax);
String result = out.toString();
This uses Jena's built-in writers that can already output RDF graphs in the various supported RDF syntaxes, such as RDF/XML and Turtle and N-Triples. If you just want to dump to System.out
, then it's even easier:
model.write(System.out, "RDF/XML-ABBREV");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With