jena安装以及环境配置参考:https://blog.csdn.net/u013819513/article/details/79903106
创建,编辑,输出RDF三元组数据,并保存至文件里,再sparql检索。
例如:
person1 name 张三
person2 name 李四
person3 name 王五
person4 name 赵六
import java.io.FileWriter;
import java.io.IOException;
import org.apache.jena.rdf.model.Model;
import org.apache.jena.rdf.model.ModelFactory;
import org.apache.jena.rdf.model.Property;
import org.apache.jena.rdf.model.RDFNode;
import org.apache.jena.rdf.model.Resource;
import org.apache.jena.rdf.model.Statement;
import org.apache.jena.rdf.model.StmtIterator;
import org.apache.jena.vocabulary.VCARD;
public class CreateRDF {
public static void main(String[] args) {
String[] personURI ={ "http://somewhere/Person1", "http://somewhere/Person2",
"http://somewhere/Person3","http://somewhere/Person4"};
S