Updating an OWL Problem Using the JENA and Protege Library

I cannot save an update to a record in my OWL RDF / XML file using Protege. Every time I close the application, I lose all my editing. I used the JENA library to read this file as follows:

OntModel model = ModelFactory.createOntologyModel (OntModelSpec.OWL_DL_MEM,null); model.setNsPrefix("", ns); FileInputStream fis = new FileInputStream(this.sourceFile); model.read(fis,ns); 

I tried to fix this problem:

 FileOutputStream fos = new FileOutputStream(this.sourceFile); model.writeAll(fos, "RDF/XML-ABBREV","xmlbase"); model.close(); 

But my file closes and is finally empty. If I try to rename the output file, it works fine (try to avoid the output file matching the input file).

At the end, my question is: how can I update my OWL file?

+4
source share
1 answer

I would say that you need to be sure that you close both threads correctly. In particular, you must close fis before opening fos for the same file name.

By the way, "xmlbase" not a valid base URI for writing a model. If you do not want to use a base URI to generate a relative URI in the body of the output document, skip null for this argument.

0
source

All Articles