You are trying to read from the downloaded contents of the file directly
which is not going to work.  The model.read() API takes in a name of a
file/URI to read or it takes in an InputStream.

Simply pass your input stream directly to the read() call, or even simpler
pass your URI to the read() call and let Jena handle the HTTP request for
you.

Rob

On 12/02/2014 12:28, "Julien Plu" <julien....@redaction-developpez.com>
wrote:

>Hi,
>
>In getting the Turtle RDF from this URI :
>https://www.googleapis.com/freebase/v1/rdf/m/020c55
>
>A RiotNotFoundException is thrown :
>
>org.apache.jena.riot.RiotNotFoundException: Not found: @prefix key: <
>http://rdf.freebase.com/key/>.
>@prefix ns: <http://rdf.freebase.com/ns/>.
>@prefix owl: <http://www.w3.org/2002/07/owl#>.
>@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
>@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
>.....
>.....
>at org.apache.jena.riot.RDFDataMgr.open(RDFDataMgr.java:831)
>        at org.apache.jena.riot.RDFDataMgr.open(RDFDataMgr.java:813)
>        at org.apache.jena.riot.RDFDataMgr.parse(RDFDataMgr.java:684)
>        at org.apache.jena.riot.RDFDataMgr.read(RDFDataMgr.java:208)
>        at org.apache.jena.riot.RDFDataMgr.read(RDFDataMgr.java:181)
>        at org.apache.jena.riot.RDFDataMgr.read(RDFDataMgr.java:119)
>        at org.apache.jena.riot.RDFDataMgr.read(RDFDataMgr.java:110)
>        at
>org.apache.jena.riot.adapters.RDFReaderRIOT.read(RDFReaderRIOT.java:77)
>        at com.hp.hpl.jena.rdf.model.impl.ModelCom.read(ModelCom.java:259)
>        at freebase.Test.main(Test.java:61)
>
>Here my code :
>
>try {
>      URL serviceURL = new URL("
>https://www.googleapis.com/freebase/v1/rdf/m/020c55";);
>      Model model = ModelFactory.createDefaultModel();
>      BufferedReader in = new BufferedReader(new
>InputStreamReader(serviceURL.openStream(), "UTF-8"));
>      String readline;
>      StringBuilder sb = new StringBuilder();
>      while ((readline = in.readLine()) != null) {
>          sb.append(readline+"\n");
>      }
>      model.read(sb.toString(), "TTL");
>    } catch (Exception ex) {
>      ex.printStackTrace();
>    }
>
>Any solution to solve this ?
>
>Thanks in advance.
>
>Best.
>
>Julien.




Reply via email to