That code doesn't write to disk, so it's impossible. The only part that COULD write to file, but doesn't is
FileWriter out=new FileWriter(file); I'm sure that it's not the whole code, so it's impossible to help. Moreover, it's more a Java related question - nothing for the Jena mailing list. > Hi > > I am very surprised that this code, when executed, has vanished my ontology > and my ontology is now empty. I copied another ontology and after executing > few times, again the new ontology is empty. I just want to create the > individual of class and save it locally in the file. There is another > method also in my code but thats just read the file so the main trick is > here. It writed the whole ontology first as model.write() but when GUI > loads and I enter text, again it display output as in > JOptionPane.showMessageDialog() but after the whole exection, the Protege > ontology becomes empty. > > > *Note: It also create the intended individual but except the User1 class > created in Jena code and its individual, nothing remains in ontology.* > > > > public static void readOntology(String file,OntModel model) > > { > > > InputStream in =FileManager.get().open(file); > > > > if (in==null) { > > throw new IllegalArgumentException( "File: " + file + " not found"); > > } > > model.read(in,"RDF/XML-ABBREV"); > > //in.close(); > > > > model.write(System.out); > > > > } > > > > > > private static void read1(String str,OntModel model) > > { > > > > String ns="http://www.semanticweb.org/untitled-ontology-0012/"; > > OntClass user = model.createClass(ns + "User"); > > > > OntClass user1 = model.getOntClass(ns + "User"); > > Individual janeSmith = user1.createIndividual(ns + str); > > > > JOptionPane.showMessageDialog(null, janeSmith.toString()); > > > > try { > > String file="F://hello.owl"; > > > > > > FileWriter out=new FileWriter(file); > -- Lorenz Bühmann AKSW group, University of Leipzig Group: http://aksw.org - semantic web research center