import java.io.FileOutputStream;
import java.io.InputStream;
import com.hp.hpl.jena.ontology.OntModel;
import com.hp.hpl.jena.ontology.ProfileRegistry;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.rdf.model.RDFWriter;
import com.hp.hpl.jena.util.FileManager;

public class Ontology {

public static void main(String[] args) {

String NS = "http://localhost/owl/ontologies/university/#";
String xmlbase = NS;

OntModel m = ModelFactory.createOntologyModel(ProfileRegistry.OWL_LANG);

RDFWriter rdfw = m.getWriter("RDF/XML-ABBREV");
rdfw.setProperty("xmlbase", xmlbase);
rdfw.setProperty("relativeURIs", "");

String dosya = "C:/university.owl";

InputStream in = FileManager.get().open(dosya);

if (in == null) {
throw new IllegalArgumentException(dosya
+ " bulunamadi");
}
//Ontoloji modeli okuma islemini yapar
m.read(in, xmlbase);
//okunan modeli konsolda ekrana yazdirir
m.write(System.out);

}

}

Yukarıdaki kodun çalışması için bir önceki yazımda anlattığım üzere c nin altında university.owl dosyası olması gerekiyor.