Question

I'm trying to import an RDF/XML file with Apache Jena using the following code from the tutorial:

Path input = Paths.get("C:\Users\Admin\Documents");
Model model = ModelFactory.createDefaultModel() ; 
model.read(input+File.separator+"foaf.rdf", "RDF/XML") ;

The file being imported is here.

When I run the test code, the following exception is returned:

Exception in thread "main" org.apache.jena.riot.RiotException: <C:\Users\Admin\Documents\foaf.rdf> 
  Code: 11/LOWERCASE_PREFERRED in SCHEME: 
    lowercase is preferred in this component

The message is really useful and self-explanatory! However, do you have a solution to this problem?

Was it helpful?

Solution

The problem is that it's expecting a URI, not a file name. It's treating C:... as an (unknown) URI scheme 'C'.

Try the following instead:

Path input = Paths.get("C:\Users\Admin\Documents", "foaf.rdf");
Model model = ModelFactory.createDefaultModel() ; 
model.read(input.toUri().toString(), "RDF/XML") ;

OTHER TIPS

I have no idea what apache jena is or does but you could try lowercasing "c:" but this probably won't work so you could try

file:/c:/my/path
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top