As you have already learned about controlling prefix, generating RDF files and about RDF Iterators in the previous examples, so in this section we are going to describe how to run simple query on the RDF graph model. Now lets see the example that can fires a simple query. The example is going to list the subject with property name "VCARD.FN".
To do this we have taken an object of Model interface. By the use of listSubjectsWithProperty() method we have queried about VCARD.FN . It returns an object of ResIterator (i.e ResourceIterator).
"Resource res = iter.nextResource();"
Above line of code gets all the resources of that particular Subject. Now we can get property and other information's of that resource.
getProperty() gets property of that resource.
getURI() will gets URI of that resource.
RDFQuery.java
import java.io.*;
|
To run this example follow these steps:
Output:

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: Simple Query on RDF file in Java
Post your Comment