OWLOntologyFormat format = manager.getOntologyFormat(ontology);
// We can save the ontology in a different format Lets save the ontology in owl/xml format
OWLXMLOntologyFormat owlxmlFormat = new OWLXMLOntologyFormat();
// Some ontology formats support prefix names and prefix IRIs. In our
// case we loaded the pizza ontology from an rdf/xml format, which
// supports prefixes. When we save the ontology in the new format we
// will copy the prefixes over so that we have nicely abbreviated IRIs
// in the new ontology document
if (format.isPrefixOWLOntologyFormat()) {
owlxmlFormat.copyPrefixesFrom(format.asPrefixOWLOntologyFormat());
}
manager.saveOntology(ontology, owlxmlFormat, IRI.create(file.toURI()));
}