Mohamed Gharibi Mohamed Gharibi - 5 months ago 27
Apache Configuration Question

Illegal unicode escape sequence value: \n (0x6E)

I am trying to convert my RDFs triples to RDFs quads (adding the context), Here is a picture of my triples (input):
enter image description here

This is my code

public static void main(String[] args) {
try {

Model model = RDFDataMgr.loadModel("/Users/mohamedghribi/Downloads/Thesis/csv2rdf-master/csv2rdf-master/examples/cars/last.nt");
DatasetGraph dsg = new DatasetGraphSimpleMem(); // very simple implementation
StmtIterator iter = model.listStatements();
PrintStream out = new PrintStream(new FileOutputStream("output.nq"));

//Iterate through each triple and add context and add the quad to the datasetgraph which is written
//in N-Quads format
while (iter.hasNext()) {
Statement stmt = iter.nextStatement(); // get next statement
Resource subject = stmt.getSubject(); // get the subject
Property predicate = stmt.getPredicate(); // get the predicate
Literal object = (Literal)stmt.getObject();// get the object

Quad quad = new Quad(NodeFactory.createURI("/Users/mohamedghribi/Downloads/Thesis/csv2rdf-master/csv2rdf-master/examples/cars/Med2.csv"),


RDFDataMgr.write(System.out, dsg, RDFFormat.NQUADS); // or NQUADS
}catch (Exception e)

But I am getting this error:

log4j:WARN No appenders could be found for logger (
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See for more info.
org.apache.jena.riot.RiotException: [line: 1, col: 62] Illegal unicode escape sequence value: \n (0x6E)
at org.apache.jena.riot.system.ErrorHandlerFactory$ErrorHandlerStd.fatal(
at org.apache.jena.riot.lang.LangEngine.raiseException(
at org.apache.jena.riot.lang.LangEngine.<init>(
at org.apache.jena.riot.lang.LangBase.<init>(
at org.apache.jena.riot.lang.LangNTuple.<init>(
at org.apache.jena.riot.lang.LangNTriples.<init>(
at org.apache.jena.riot.RiotReader.createParserNTriples(
at org.apache.jena.riot.RiotReader.createParser(
at org.apache.jena.riot.RiotReader.createParser(
at org.apache.jena.riot.RDFParserRegistry$
at org.apache.jena.riot.RDFDataMgr.process(
at org.apache.jena.riot.RDFDataMgr.parse(
at org.apache.jena.riot.RDFDataMgr.loadModel(
at Triple2Quad.main(
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
at java.lang.reflect.Method.invoke(
at com.intellij.rt.execution.application.AppMain.main(

Process finished with exit code 0

I think the error in the spaces or the backslash
. So how can i solve that ?


\n is illegal in an IRI.

Fix the data by changing the IRIs

Maybe replace \n by %0A (note: there will really be %-0-A in the data URI- this is not an escape mechanism).

Or fix the IRI to what it is supposed to be. Use a legal character as a separator or delete the \n.