Jena操作本体的持久化方法(一):持久化到文件
我们假设已经使用protege等可视化工具创建了我们需要的本体,然后我们需要用Jena提供的API对其进行操作,比如,创建实例,查询,推理等等,我们需要有一种方法将本体持久化,持久化到硬盘文件是一种很常见的选择。
从硬盘读取本体文件的方法:
void readModel(OntModel m,String filePath){
m.read(filePath);
}
m.read(filePath);
}
将本体持久化到硬盘文件的方法 :
void writefile(OntModel m,String filePath){
File file=new File(filePath);
try{
OutputStream outer=new FileOutputStream(file);
}catch (FileNotFoundException e){
}
m.write(outer,”RDF/XML-ABBREV”);//”RDF/XML-ABBREV”–Human readable style…
}
File file=new File(filePath);
try{
OutputStream outer=new FileOutputStream(file);
}catch (FileNotFoundException e){
}
m.write(outer,”RDF/XML-ABBREV”);//”RDF/XML-ABBREV”–Human readable style…
}
Posted in » Days of Our Life, Semantic Web |





