1.) This is not a minimal running example! that means, nobody can test
it without some (in your case too much) effort to get it running.
2.) w.r.t. 1), look at your main() method, it reads a file and then?
2.) Please tell us exactly WHAT does not work and WHAT you expect.
3.) The OntModel object has a method write, not sure what you did there
with calling getWriter and the like
> *When I run this program without writing it to the file, it runs smoothly.
> But when I copy it to a file (both newly created and existing file),
> sometime it adds the garbage claases to the file like Seq, Bag, Resource
> and most of the time it does nothing except it empties the destination
> file.*
>
> *I have copied the whole code except the code auto generated by netbeans*
>
>
>
>
>
> *public class NewJFrame extends javax.swing.JFrame {*
>
>
>
>
>
>
> * 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,null);*
>
> * //in.close();}}*
>
>
>
> private void read1(String str, OntModel model)
>
> {
>
>
>
>
>
>
>
> String ns="
> http://www.semanticweb.org/ontologies/untitled-ontology-54/";
>
>
> OntClass user = model.createClass(ns + "User");
>
>
>
>
>
> OntClass user1 = model.getOntClass(ns + "User");
>
> Individual janeSmith = user1.createIndividual(ns + str)
>
>
>
> try {
>
> String file="F://newontology.owl";
>
>
>
>
>
> FileOutputStream f1=new FileOutputStream(file);
>
> RDFWriter d = model.getWriter("RDF/XML-ABBREV");
>
> d.write(model,f1,null);
>
> }catch(Exception e) {}
>
>
> *private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
> *
>
>
>
> *OntModel model=ModelFactory.createOntologyModel();*
>
>
> * String str=jTextField2.getText()*
>
>
>
> * read1(str, model); }}*
>
>
>
> * public static void main(String args[]) {*
>
>
>
>
>
>
>
> * OntModel model = ModelFactory.createOntologyModel();*
>
> * String file="F://updated.owl";*
>
> * readOntology(file , model );*
>
> *}*
>
--
Lorenz Bühmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center