package test;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.Iterator;
import com.hp.hpl.jena.ontology.OntClass;
import com.hp.hpl.jena.ontology.OntModel;
import com.hp.hpl.jena.ontology.OntModelSpec;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.ontology.*;
public class testjena {
public static void main(String[] args) throws UnsupportedEncodingException {
String owlPath = "e: // bis London target ontology .owl";
// Create an instance of body
OntModel ontModel = ModelFactory
.createOntologyModel(OntModelSpec.OWL_MEM);
// Load the document body
ontModel.read("file:" + owlPath, "RDF/XML");
String temp = "";
// Iterate read all the nodes in the body
for (Iterator i = ontModel.listClasses(); i.hasNext();) {
OntClass c = (OntClass) i.next();
c.listSuperClasses();
if (!c.isAnon()) {
String tmp = c.getLocalName().toString();
// get node body, as a character string stored in the variable temp
tmp = new String(tmp.getBytes("UTF-8"), "UTF-8");
temp += tmp + "\r\n";
System.out.println(temp);
}
}
// create the model and import owl file
}}
import java.io.FileInputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.Iterator;
import com.hp.hpl.jena.ontology.OntClass;
import com.hp.hpl.jena.ontology.OntModel;
import com.hp.hpl.jena.ontology.OntModelSpec;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.ontology.*;
public class testjena {
public static void main(String[] args) throws UnsupportedEncodingException {
String owlPath = "e: // bis London target ontology .owl";
// Create an instance of body
OntModel ontModel = ModelFactory
.createOntologyModel(OntModelSpec.OWL_MEM);
// Load the document body
ontModel.read("file:" + owlPath, "RDF/XML");
String temp = "";
// Iterate read all the nodes in the body
for (Iterator i = ontModel.listClasses(); i.hasNext();) {
OntClass c = (OntClass) i.next();
c.listSuperClasses();
if (!c.isAnon()) {
String tmp = c.getLocalName().toString();
// get node body, as a character string stored in the variable temp
tmp = new String(tmp.getBytes("UTF-8"), "UTF-8");
temp += tmp + "\r\n";
System.out.println(temp);
}
}
// create the model and import owl file
}}