I have successfully read a file into a model using the following code based
on the some of the documented examples.

String inputfile = "c://myfile.ttl";
// create an empty model
com.hp.hpl.jena.rdf.model.Model model=
com.hp.hpl.jena.rdf.model.ModelFactory.createDefaultModel();
java.io.InputStream in = com.hp.hpl.jena.util.FileManager.get().open(
inputfile);
if (in == null) {
throw new IllegalArgumentException( "File: " + inputfile+ " not found");}

// read the  file
model.read(in, "*TURTLE*");

However I noticed in the javadoc that the FileManager also has a few means
of reading a file e.g.
FileManager.*loadModel<http://jena.apache.org/documentation/javadoc/jena/com/hp/hpl/jena/util/FileManager.html#loadModel%28java.lang.String,%20java.lang.String%29>
*(String<http://docs.oracle.com/javase/6/docs/api/java/lang/String.html?is-external=true>
filenameOrURI,
String<http://docs.oracle.com/javase/6/docs/api/java/lang/String.html?is-external=true>
 rdfSyntax)
FileManager.*readModel<http://jena.apache.org/documentation/javadoc/jena/com/hp/hpl/jena/util/FileManager.html#readModel%28com.hp.hpl.jena.rdf.model.Model,%20java.lang.String,%20java.lang.String%29>
*(Model<http://jena.apache.org/documentation/javadoc/jena/com/hp/hpl/jena/rdf/model/Model.html>
model,
String<http://docs.oracle.com/javase/6/docs/api/java/lang/String.html?is-external=true>
filenameOrURI,
String<http://docs.oracle.com/javase/6/docs/api/java/lang/String.html?is-external=true>
 rdfSyntax)

I was wonder which is the best to use in which situation?
I can see in the last two I don’t need to create a stream myself but
I’m unsure if they
have additional pros or cons.

Thanks in advance

Phil

Reply via email to