You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by "Zlatareva, Neli (Computer Science)" <Zl...@ccsu.edu> on 2018/07/13 08:37:45 UTC

reading a ttl file from remote location for quering

Hi, I am trying to access a remote Turtle file for querying with no success ( I tried libraries from the latest Apache Jena and earlier Jena versions)

I can read a local file as follows and it works fine:


Model model = ModelFactory.createDefaultModel();
model.read(new FileInputStream("C:/Users/myDir/eclipse-workspace/Example/src/TryFriends.ttl"),null,"TTL");

I can query TryFriends.ttl, but if I try to access it remotely by providing a URL, I can't make it work no matter what I tried. That is,

model.read(new FileInputStream("http://www.cs.ccsu.edu/~neli/TryFriends.ttl"),null,"TTL");  does not work

Here is the error I get

Exception in thread "main" java.io.FileNotFoundException: http:\www.cs.ccsu.edu\~neli\TryFriends.ttl (The filename, directory name, or volume label syntax is incorrect)
 at java.io.FileInputStream.open0(Native Method)
 at java.io.FileInputStream.open(Unknown Source)
 at java.io.FileInputStream.<init>(Unknown Source)
 at java.io.FileInputStream.<init>(Unknown Source)
 at CCExample2.main(CCExample2.java:18)

Any help will be greatly appreciated.
Thanks a lot.
Regards, Neli.



Re: reading a ttl file from remote location for quering

Posted by "Zlatareva, Neli (Computer Science)" <Zl...@ccsu.edu>.
Yes, I saw that -- it is indeed strange. I'll try to check with my school to ensure that there are no security restrictions on accessing .ttl files. Thanks a lot.


Neli P. Zlatareva, PhD
Professor of Computer Science
Department of Computer Science
Central Connecticut State University
New Britain, CT 06050
Phone: (860) 832-2723
Fax: (860) 832-2712
Web site: cs.ccsu.edu/~neli/
________________________________
From: ajs6f <aj...@apache.org>
Sent: Friday, July 13, 2018 8:45:37 AM
To: users@jena.apache.org
Subject: Re: reading a ttl file from remote location for quering

This:

> Encountered: " " (32), after : "<!DOCTYPE"

seems a bit odd-- that looks like an XML header. When I go to the address of your data file (https://na01.safelinks.protection.outlook.com/?url=http:%2F%2Fwww.cs.ccsu.edu%2F~neli%2FTryFriends.ttl&amp;data=01%7C01%7CZlatareva%40ccsu.edu%7Cfacb269544594bb0621b08d5e8be8fc2%7C2329c570b5804223803b427d800e81b6%7C0&amp;sdata=m7%2FKT6hQ4MKyY54i5p%2FrUgp4rCaMy9MZ5jZ0wS34is0%3D&amp;reserved=0) I get redirected to http://www.ccsu.edu/cs/, which indeed begins with "<!DOCTYPE", and is certainly not Turtle or any other RDF format.

Are you sure that the URL for your data is correct?

ajs6f

> On Jul 13, 2018, at 8:39 AM, Andy Seaborne <an...@apache.org> wrote:
>
>
>
>
>
> On 13/07/18 13:16, Zlatareva, Neli (Computer Science) wrote:
>> Hi Rob, thank you so much for quick reply. I did try that, i.e.
>> model.read("https://na01.safelinks.protection.outlook.com/?url=http:%2F%2Fwww.cs.ccsu.edu%2F~neli%2FTryFriends.ttl&amp;data=01%7C01%7CZlatareva%40ccsu.edu%7Cfacb269544594bb0621b08d5e8be8fc2%7C2329c570b5804223803b427d800e81b6%7C0&amp;sdata=m7%2FKT6hQ4MKyY54i5p%2FrUgp4rCaMy9MZ5jZ0wS34is0%3D&amp;reserved=0", null, "TTL");
>> but I get the following error
>> Exception in thread "main" com.hp.hpl.jena.n3.turtle.TurtleParseException: Lexical error at line 1, column 10.  Encountered: " " (32), after : "<!DOCTYPE"
>>  at com.hp.hpl.jena.n3.turtle.ParserTurtle.parse(ParserTurtle.java:44)
>>  at com.hp.hpl.jena.n3.turtle.TurtleReader.readWorker(TurtleReader.java:20)
>>  at com.hp.hpl.jena.n3.JenaReaderBase.readImpl(JenaReaderBase.java:101)
>>  at com.hp.hpl.jena.n3.JenaReaderBase.read(JenaReaderBase.java:68)
>>  at com.hp.hpl.jena.rdf.model.impl.ModelCom.read(ModelCom.java:225)
>>  at com.hp.hpl.jena.rdf.model.impl.ModelCom.read(ModelCom.java:210)
>>  at CCExample3.main(CCExample3.java:18)
>
> com.hp.hpl.jena ==> a quite old version of Jena, not fully RDF 1.1.
>
> Either very old or you also only have some of the jena jars on the classpath.
>
> Maure jena-arq in on the classpath - it has the standards compliant Turtle parser.
>
> Once you are using the right code:
>
> RDFDataMgr.read(model, "https://na01.safelinks.protection.outlook.com/?url=http:%2F%2Fwww.cs.ccsu.edu%2F~neli%2FTryFriends.ttl&amp;data=01%7C01%7CZlatareva%40ccsu.edu%7Cfacb269544594bb0621b08d5e8be8fc2%7C2329c570b5804223803b427d800e81b6%7C0&amp;sdata=m7%2FKT6hQ4MKyY54i5p%2FrUgp4rCaMy9MZ5jZ0wS34is0%3D&amp;reserved=0");
>
>        Andy
>
>
>> Is there something else I can try?
>> THANK YOU!
>> ________________________________
>> From: Rob Vesse <rv...@dotnetrdf.org>
>> Sent: Friday, July 13, 2018 4:48:49 AM
>> To: users@jena.apache.org
>> Subject: Re: reading a ttl file from remote location for quering
>> FileInputStream is used for accessing local files, this is a standard Java component.  It cannot be used to read remote URLs.
>> There is actually no need to explicitly specify a stream here, you can simply provide the URL as a string and Jena will do the right thing i.e.
>> model.read("https://na01.safelinks.protection.outlook.com/?url=http:%2F%2Fwww.cs.ccsu.edu%2F~neli%2FTryFriends.ttl&data=01%7C01%7CZlatareva%40ccsu.edu%7C1183efa6d8f649f27be708d5e89d8f2b%7C2329c570b5804223803b427d800e81b6%7C0&sdata=p4v6eaSyx2m7mSiJPKqaqrjHJO2oAJ7SXdQ2WlRAPnw%3D&reserved=0", null, "TTL");
>> Or similarly when using a local path:
>> model.read("C:/Users/myDir/eclipse-workspace/Example/src/TryFriends.ttl", null, "TTL")
>> Rob
>> On 13/07/2018, 09:38, "Zlatareva, Neli (Computer Science)" <Zl...@ccsu.edu> wrote:
>>     Hi, I am trying to access a remote Turtle file for querying with no success ( I tried libraries from the latest Apache Jena and earlier Jena versions)
>>     I can read a local file as follows and it works fine:
>>     Model model = ModelFactory.createDefaultModel();
>>     model.read(new FileInputStream("C:/Users/myDir/eclipse-workspace/Example/src/TryFriends.ttl"),null,"TTL");
>>     I can query TryFriends.ttl, but if I try to access it remotely by providing a URL, I can't make it work no matter what I tried. That is,
>>     model.read(new FileInputStream("https://na01.safelinks.protection.outlook.com/?url=http:%2F%2Fwww.cs.ccsu.edu%2F~neli%2FTryFriends.ttl&data=01%7C01%7CZlatareva%40ccsu.edu%7C1183efa6d8f649f27be708d5e89d8f2b%7C2329c570b5804223803b427d800e81b6%7C0&sdata=p4v6eaSyx2m7mSiJPKqaqrjHJO2oAJ7SXdQ2WlRAPnw%3D&reserved=0"),null,"TTL");  does not work
>>     Here is the error I get
>>     Exception in thread "main" java.io.FileNotFoundException: http:\www.cs.ccsu.edu\~neli\TryFriends.ttl (The filename, directory name, or volume label syntax is incorrect)
>>      at java.io.FileInputStream.open0(Native Method)
>>      at java.io.FileInputStream.open(Unknown Source)
>>      at java.io.FileInputStream.<init>(Unknown Source)
>>      at java.io.FileInputStream.<init>(Unknown Source)
>>      at CCExample2.main(CCExample2.java:18)
>>     Any help will be greatly appreciated.
>>     Thanks a lot.
>>     Regards, Neli.


Re: reading a ttl file from remote location for quering

Posted by ajs6f <aj...@apache.org>.
This:

> Encountered: " " (32), after : "<!DOCTYPE"

seems a bit odd-- that looks like an XML header. When I go to the address of your data file (http://www.cs.ccsu.edu/~neli/TryFriends.ttl) I get redirected to http://www.ccsu.edu/cs/, which indeed begins with "<!DOCTYPE", and is certainly not Turtle or any other RDF format.

Are you sure that the URL for your data is correct?

ajs6f

> On Jul 13, 2018, at 8:39 AM, Andy Seaborne <an...@apache.org> wrote:
> 
> 
> 
> 
> 
> On 13/07/18 13:16, Zlatareva, Neli (Computer Science) wrote:
>> Hi Rob, thank you so much for quick reply. I did try that, i.e.
>> model.read("http://www.cs.ccsu.edu/~neli/TryFriends.ttl", null, "TTL");
>> but I get the following error
>> Exception in thread "main" com.hp.hpl.jena.n3.turtle.TurtleParseException: Lexical error at line 1, column 10.  Encountered: " " (32), after : "<!DOCTYPE"
>>  at com.hp.hpl.jena.n3.turtle.ParserTurtle.parse(ParserTurtle.java:44)
>>  at com.hp.hpl.jena.n3.turtle.TurtleReader.readWorker(TurtleReader.java:20)
>>  at com.hp.hpl.jena.n3.JenaReaderBase.readImpl(JenaReaderBase.java:101)
>>  at com.hp.hpl.jena.n3.JenaReaderBase.read(JenaReaderBase.java:68)
>>  at com.hp.hpl.jena.rdf.model.impl.ModelCom.read(ModelCom.java:225)
>>  at com.hp.hpl.jena.rdf.model.impl.ModelCom.read(ModelCom.java:210)
>>  at CCExample3.main(CCExample3.java:18)
> 
> com.hp.hpl.jena ==> a quite old version of Jena, not fully RDF 1.1.
> 
> Either very old or you also only have some of the jena jars on the classpath.
> 
> Maure jena-arq in on the classpath - it has the standards compliant Turtle parser.
> 
> Once you are using the right code:
> 
> RDFDataMgr.read(model, "http://www.cs.ccsu.edu/~neli/TryFriends.ttl");
> 
> 	Andy
> 
> 
>> Is there something else I can try?
>> THANK YOU!
>> ________________________________
>> From: Rob Vesse <rv...@dotnetrdf.org>
>> Sent: Friday, July 13, 2018 4:48:49 AM
>> To: users@jena.apache.org
>> Subject: Re: reading a ttl file from remote location for quering
>> FileInputStream is used for accessing local files, this is a standard Java component.  It cannot be used to read remote URLs.
>> There is actually no need to explicitly specify a stream here, you can simply provide the URL as a string and Jena will do the right thing i.e.
>> model.read("https://na01.safelinks.protection.outlook.com/?url=http:%2F%2Fwww.cs.ccsu.edu%2F~neli%2FTryFriends.ttl&amp;data=01%7C01%7CZlatareva%40ccsu.edu%7C1183efa6d8f649f27be708d5e89d8f2b%7C2329c570b5804223803b427d800e81b6%7C0&amp;sdata=p4v6eaSyx2m7mSiJPKqaqrjHJO2oAJ7SXdQ2WlRAPnw%3D&amp;reserved=0", null, "TTL");
>> Or similarly when using a local path:
>> model.read("C:/Users/myDir/eclipse-workspace/Example/src/TryFriends.ttl", null, "TTL")
>> Rob
>> On 13/07/2018, 09:38, "Zlatareva, Neli (Computer Science)" <Zl...@ccsu.edu> wrote:
>>     Hi, I am trying to access a remote Turtle file for querying with no success ( I tried libraries from the latest Apache Jena and earlier Jena versions)
>>     I can read a local file as follows and it works fine:
>>     Model model = ModelFactory.createDefaultModel();
>>     model.read(new FileInputStream("C:/Users/myDir/eclipse-workspace/Example/src/TryFriends.ttl"),null,"TTL");
>>     I can query TryFriends.ttl, but if I try to access it remotely by providing a URL, I can't make it work no matter what I tried. That is,
>>     model.read(new FileInputStream("https://na01.safelinks.protection.outlook.com/?url=http:%2F%2Fwww.cs.ccsu.edu%2F~neli%2FTryFriends.ttl&amp;data=01%7C01%7CZlatareva%40ccsu.edu%7C1183efa6d8f649f27be708d5e89d8f2b%7C2329c570b5804223803b427d800e81b6%7C0&amp;sdata=p4v6eaSyx2m7mSiJPKqaqrjHJO2oAJ7SXdQ2WlRAPnw%3D&amp;reserved=0"),null,"TTL");  does not work
>>     Here is the error I get
>>     Exception in thread "main" java.io.FileNotFoundException: http:\www.cs.ccsu.edu\~neli\TryFriends.ttl (The filename, directory name, or volume label syntax is incorrect)
>>      at java.io.FileInputStream.open0(Native Method)
>>      at java.io.FileInputStream.open(Unknown Source)
>>      at java.io.FileInputStream.<init>(Unknown Source)
>>      at java.io.FileInputStream.<init>(Unknown Source)
>>      at CCExample2.main(CCExample2.java:18)
>>     Any help will be greatly appreciated.
>>     Thanks a lot.
>>     Regards, Neli.


Re: reading a ttl file from remote location for quering

Posted by Andy Seaborne <an...@apache.org>.



On 13/07/18 13:16, Zlatareva, Neli (Computer Science) wrote:
> Hi Rob, thank you so much for quick reply. I did try that, i.e.
> 
> model.read("http://www.cs.ccsu.edu/~neli/TryFriends.ttl", null, "TTL");
> 
> but I get the following error
> 
> 
> Exception in thread "main" com.hp.hpl.jena.n3.turtle.TurtleParseException: Lexical error at line 1, column 10.  Encountered: " " (32), after : "<!DOCTYPE"
>   at com.hp.hpl.jena.n3.turtle.ParserTurtle.parse(ParserTurtle.java:44)
>   at com.hp.hpl.jena.n3.turtle.TurtleReader.readWorker(TurtleReader.java:20)
>   at com.hp.hpl.jena.n3.JenaReaderBase.readImpl(JenaReaderBase.java:101)
>   at com.hp.hpl.jena.n3.JenaReaderBase.read(JenaReaderBase.java:68)
>   at com.hp.hpl.jena.rdf.model.impl.ModelCom.read(ModelCom.java:225)
>   at com.hp.hpl.jena.rdf.model.impl.ModelCom.read(ModelCom.java:210)
>   at CCExample3.main(CCExample3.java:18)

com.hp.hpl.jena ==> a quite old version of Jena, not fully RDF 1.1.

Either very old or you also only have some of the jena jars on the 
classpath.

Maure jena-arq in on the classpath - it has the standards compliant 
Turtle parser.

Once you are using the right code:

RDFDataMgr.read(model, "http://www.cs.ccsu.edu/~neli/TryFriends.ttl");

	Andy


> 
> Is there something else I can try?
> THANK YOU!
> 
> ________________________________
> From: Rob Vesse <rv...@dotnetrdf.org>
> Sent: Friday, July 13, 2018 4:48:49 AM
> To: users@jena.apache.org
> Subject: Re: reading a ttl file from remote location for quering
> 
> FileInputStream is used for accessing local files, this is a standard Java component.  It cannot be used to read remote URLs.
> 
> There is actually no need to explicitly specify a stream here, you can simply provide the URL as a string and Jena will do the right thing i.e.
> 
> model.read("https://na01.safelinks.protection.outlook.com/?url=http:%2F%2Fwww.cs.ccsu.edu%2F~neli%2FTryFriends.ttl&amp;data=01%7C01%7CZlatareva%40ccsu.edu%7C1183efa6d8f649f27be708d5e89d8f2b%7C2329c570b5804223803b427d800e81b6%7C0&amp;sdata=p4v6eaSyx2m7mSiJPKqaqrjHJO2oAJ7SXdQ2WlRAPnw%3D&amp;reserved=0", null, "TTL");
> 
> Or similarly when using a local path:
> 
> model.read("C:/Users/myDir/eclipse-workspace/Example/src/TryFriends.ttl", null, "TTL")
> 
> Rob
> 
> On 13/07/2018, 09:38, "Zlatareva, Neli (Computer Science)" <Zl...@ccsu.edu> wrote:
> 
>      Hi, I am trying to access a remote Turtle file for querying with no success ( I tried libraries from the latest Apache Jena and earlier Jena versions)
> 
>      I can read a local file as follows and it works fine:
> 
> 
>      Model model = ModelFactory.createDefaultModel();
>      model.read(new FileInputStream("C:/Users/myDir/eclipse-workspace/Example/src/TryFriends.ttl"),null,"TTL");
> 
>      I can query TryFriends.ttl, but if I try to access it remotely by providing a URL, I can't make it work no matter what I tried. That is,
> 
>      model.read(new FileInputStream("https://na01.safelinks.protection.outlook.com/?url=http:%2F%2Fwww.cs.ccsu.edu%2F~neli%2FTryFriends.ttl&amp;data=01%7C01%7CZlatareva%40ccsu.edu%7C1183efa6d8f649f27be708d5e89d8f2b%7C2329c570b5804223803b427d800e81b6%7C0&amp;sdata=p4v6eaSyx2m7mSiJPKqaqrjHJO2oAJ7SXdQ2WlRAPnw%3D&amp;reserved=0"),null,"TTL");  does not work
> 
>      Here is the error I get
> 
>      Exception in thread "main" java.io.FileNotFoundException: http:\www.cs.ccsu.edu\~neli\TryFriends.ttl (The filename, directory name, or volume label syntax is incorrect)
>       at java.io.FileInputStream.open0(Native Method)
>       at java.io.FileInputStream.open(Unknown Source)
>       at java.io.FileInputStream.<init>(Unknown Source)
>       at java.io.FileInputStream.<init>(Unknown Source)
>       at CCExample2.main(CCExample2.java:18)
> 
>      Any help will be greatly appreciated.
>      Thanks a lot.
>      Regards, Neli.
> 
> 
> 
> 
> 
> 
> 

Re: reading a ttl file from remote location for quering

Posted by Andy Seaborne <an...@apache.org>.

On 13/07/18 13:16, Zlatareva, Neli (Computer Science) wrote:
> Hi Rob, thank you so much for quick reply. I did try that, i.e.
> 
> model.read("http://www.cs.ccsu.edu/~neli/TryFriends.ttl", null, "TTL");
> 
> but I get the following error
> 
> 
> Exception in thread "main" com.hp.hpl.jena.n3.turtle.TurtleParseException: Lexical error at line 1, column 10.  Encountered: " " (32), after : "<!DOCTYPE"

That file is not Turtle - it is an HTML page.

For me, it's redirecting to https://www.ccsu.edu

>   at com.hp.hpl.jena.n3.turtle.ParserTurtle.parse(ParserTurtle.java:44)
>   at com.hp.hpl.jena.n3.turtle.TurtleReader.readWorker(TurtleReader.java:20)
>   at com.hp.hpl.jena.n3.JenaReaderBase.readImpl(JenaReaderBase.java:101)
>   at com.hp.hpl.jena.n3.JenaReaderBase.read(JenaReaderBase.java:68)
>   at com.hp.hpl.jena.rdf.model.impl.ModelCom.read(ModelCom.java:225)
>   at com.hp.hpl.jena.rdf.model.impl.ModelCom.read(ModelCom.java:210)
>   at CCExample3.main(CCExample3.java:18)
> 
> Is there something else I can try?
> THANK YOU!
> 
> ________________________________
> From: Rob Vesse <rv...@dotnetrdf.org>
> Sent: Friday, July 13, 2018 4:48:49 AM
> To: users@jena.apache.org
> Subject: Re: reading a ttl file from remote location for quering
> 
> FileInputStream is used for accessing local files, this is a standard Java component.  It cannot be used to read remote URLs.
> 
> There is actually no need to explicitly specify a stream here, you can simply provide the URL as a string and Jena will do the right thing i.e.
> 
> model.read("https://na01.safelinks.protection.outlook.com/?url=http:%2F%2Fwww.cs.ccsu.edu%2F~neli%2FTryFriends.ttl&amp;data=01%7C01%7CZlatareva%40ccsu.edu%7C1183efa6d8f649f27be708d5e89d8f2b%7C2329c570b5804223803b427d800e81b6%7C0&amp;sdata=p4v6eaSyx2m7mSiJPKqaqrjHJO2oAJ7SXdQ2WlRAPnw%3D&amp;reserved=0", null, "TTL");
> 
> Or similarly when using a local path:
> 
> model.read("C:/Users/myDir/eclipse-workspace/Example/src/TryFriends.ttl", null, "TTL")
> 
> Rob
> 
> On 13/07/2018, 09:38, "Zlatareva, Neli (Computer Science)" <Zl...@ccsu.edu> wrote:
> 
>      Hi, I am trying to access a remote Turtle file for querying with no success ( I tried libraries from the latest Apache Jena and earlier Jena versions)
> 
>      I can read a local file as follows and it works fine:
> 
> 
>      Model model = ModelFactory.createDefaultModel();
>      model.read(new FileInputStream("C:/Users/myDir/eclipse-workspace/Example/src/TryFriends.ttl"),null,"TTL");
> 
>      I can query TryFriends.ttl, but if I try to access it remotely by providing a URL, I can't make it work no matter what I tried. That is,
> 
>      model.read(new FileInputStream("https://na01.safelinks.protection.outlook.com/?url=http:%2F%2Fwww.cs.ccsu.edu%2F~neli%2FTryFriends.ttl&amp;data=01%7C01%7CZlatareva%40ccsu.edu%7C1183efa6d8f649f27be708d5e89d8f2b%7C2329c570b5804223803b427d800e81b6%7C0&amp;sdata=p4v6eaSyx2m7mSiJPKqaqrjHJO2oAJ7SXdQ2WlRAPnw%3D&amp;reserved=0"),null,"TTL");  does not work
> 
>      Here is the error I get
> 
>      Exception in thread "main" java.io.FileNotFoundException: http:\www.cs.ccsu.edu\~neli\TryFriends.ttl (The filename, directory name, or volume label syntax is incorrect)
>       at java.io.FileInputStream.open0(Native Method)
>       at java.io.FileInputStream.open(Unknown Source)
>       at java.io.FileInputStream.<init>(Unknown Source)
>       at java.io.FileInputStream.<init>(Unknown Source)
>       at CCExample2.main(CCExample2.java:18)
> 
>      Any help will be greatly appreciated.
>      Thanks a lot.
>      Regards, Neli.
> 
> 
> 
> 
> 
> 
> 

Re: reading a ttl file from remote location for quering

Posted by "Zlatareva, Neli (Computer Science)" <Zl...@ccsu.edu>.
Hi Rob, thank you so much for quick reply. I did try that, i.e.

model.read("http://www.cs.ccsu.edu/~neli/TryFriends.ttl", null, "TTL");

but I get the following error


Exception in thread "main" com.hp.hpl.jena.n3.turtle.TurtleParseException: Lexical error at line 1, column 10.  Encountered: " " (32), after : "<!DOCTYPE"
 at com.hp.hpl.jena.n3.turtle.ParserTurtle.parse(ParserTurtle.java:44)
 at com.hp.hpl.jena.n3.turtle.TurtleReader.readWorker(TurtleReader.java:20)
 at com.hp.hpl.jena.n3.JenaReaderBase.readImpl(JenaReaderBase.java:101)
 at com.hp.hpl.jena.n3.JenaReaderBase.read(JenaReaderBase.java:68)
 at com.hp.hpl.jena.rdf.model.impl.ModelCom.read(ModelCom.java:225)
 at com.hp.hpl.jena.rdf.model.impl.ModelCom.read(ModelCom.java:210)
 at CCExample3.main(CCExample3.java:18)

Is there something else I can try?
THANK YOU!

________________________________
From: Rob Vesse <rv...@dotnetrdf.org>
Sent: Friday, July 13, 2018 4:48:49 AM
To: users@jena.apache.org
Subject: Re: reading a ttl file from remote location for quering

FileInputStream is used for accessing local files, this is a standard Java component.  It cannot be used to read remote URLs.

There is actually no need to explicitly specify a stream here, you can simply provide the URL as a string and Jena will do the right thing i.e.

model.read("https://na01.safelinks.protection.outlook.com/?url=http:%2F%2Fwww.cs.ccsu.edu%2F~neli%2FTryFriends.ttl&amp;data=01%7C01%7CZlatareva%40ccsu.edu%7C1183efa6d8f649f27be708d5e89d8f2b%7C2329c570b5804223803b427d800e81b6%7C0&amp;sdata=p4v6eaSyx2m7mSiJPKqaqrjHJO2oAJ7SXdQ2WlRAPnw%3D&amp;reserved=0", null, "TTL");

Or similarly when using a local path:

model.read("C:/Users/myDir/eclipse-workspace/Example/src/TryFriends.ttl", null, "TTL")

Rob

On 13/07/2018, 09:38, "Zlatareva, Neli (Computer Science)" <Zl...@ccsu.edu> wrote:

    Hi, I am trying to access a remote Turtle file for querying with no success ( I tried libraries from the latest Apache Jena and earlier Jena versions)

    I can read a local file as follows and it works fine:


    Model model = ModelFactory.createDefaultModel();
    model.read(new FileInputStream("C:/Users/myDir/eclipse-workspace/Example/src/TryFriends.ttl"),null,"TTL");

    I can query TryFriends.ttl, but if I try to access it remotely by providing a URL, I can't make it work no matter what I tried. That is,

    model.read(new FileInputStream("https://na01.safelinks.protection.outlook.com/?url=http:%2F%2Fwww.cs.ccsu.edu%2F~neli%2FTryFriends.ttl&amp;data=01%7C01%7CZlatareva%40ccsu.edu%7C1183efa6d8f649f27be708d5e89d8f2b%7C2329c570b5804223803b427d800e81b6%7C0&amp;sdata=p4v6eaSyx2m7mSiJPKqaqrjHJO2oAJ7SXdQ2WlRAPnw%3D&amp;reserved=0"),null,"TTL");  does not work

    Here is the error I get

    Exception in thread "main" java.io.FileNotFoundException: http:\www.cs.ccsu.edu\~neli\TryFriends.ttl (The filename, directory name, or volume label syntax is incorrect)
     at java.io.FileInputStream.open0(Native Method)
     at java.io.FileInputStream.open(Unknown Source)
     at java.io.FileInputStream.<init>(Unknown Source)
     at java.io.FileInputStream.<init>(Unknown Source)
     at CCExample2.main(CCExample2.java:18)

    Any help will be greatly appreciated.
    Thanks a lot.
    Regards, Neli.








Re: reading a ttl file from remote location for quering

Posted by Rob Vesse <rv...@dotnetrdf.org>.
FileInputStream is used for accessing local files, this is a standard Java component.  It cannot be used to read remote URLs.

There is actually no need to explicitly specify a stream here, you can simply provide the URL as a string and Jena will do the right thing i.e.

model.read("http://www.cs.ccsu.edu/~neli/TryFriends.ttl", null, "TTL");

Or similarly when using a local path:

model.read("C:/Users/myDir/eclipse-workspace/Example/src/TryFriends.ttl", null, "TTL")

Rob

On 13/07/2018, 09:38, "Zlatareva, Neli (Computer Science)" <Zl...@ccsu.edu> wrote:

    Hi, I am trying to access a remote Turtle file for querying with no success ( I tried libraries from the latest Apache Jena and earlier Jena versions)
    
    I can read a local file as follows and it works fine:
    
    
    Model model = ModelFactory.createDefaultModel();
    model.read(new FileInputStream("C:/Users/myDir/eclipse-workspace/Example/src/TryFriends.ttl"),null,"TTL");
    
    I can query TryFriends.ttl, but if I try to access it remotely by providing a URL, I can't make it work no matter what I tried. That is,
    
    model.read(new FileInputStream("http://www.cs.ccsu.edu/~neli/TryFriends.ttl"),null,"TTL");  does not work
    
    Here is the error I get
    
    Exception in thread "main" java.io.FileNotFoundException: http:\www.cs.ccsu.edu\~neli\TryFriends.ttl (The filename, directory name, or volume label syntax is incorrect)
     at java.io.FileInputStream.open0(Native Method)
     at java.io.FileInputStream.open(Unknown Source)
     at java.io.FileInputStream.<init>(Unknown Source)
     at java.io.FileInputStream.<init>(Unknown Source)
     at CCExample2.main(CCExample2.java:18)
    
    Any help will be greatly appreciated.
    Thanks a lot.
    Regards, Neli.