Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert String to model or Statement in jena using Java program?

Tags:

java

rdf

jena

I made a program for RDF by using jena in java... I have to return the result in string format.. and then in other function i have to get it as a string format and convert it to either model or statement.... Is that possible... If so how to do that... could some one help me with a sample code...

Thanks in advance

like image 724
Sathish Kumar Avatar asked Feb 19 '26 07:02

Sathish Kumar


1 Answers

If the RDF you want to serialize is less than your complete model, then create a temporary memory model and copy into it the statements to want to write. Use Model.write to convert those statements to a string (in RDF/XML, Turtle or N-triples format). When you want to load a string containing RDF, create a java.io.StringReader object containing your string and pass that to the Model.read method.

like image 146
Ian Dickinson Avatar answered Feb 21 '26 22:02

Ian Dickinson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!