If a Turtle file has a BOM at the start then Jena will refuse to parse it giving the following error:
Exception in thread "main" com.hp.hpl.jena.n3.turtle.TurtleParseException: Lexical error at line 1, column 2. Encountered: "@" (64), after : "\ufeff"
The code I used to produce this error was as follows:
public class TurtleWithBOM
public static void main(String args)
// create an empty model
Model model = ModelFactory.createDefaultModel();
InputStream in = FileManager.get().open( "ttl-with-bom.ttl" );
if (in == null)
// read the Turtle file
model.read(in, "", "TTL");
// write it to standard out
A sample Turtle file used with the above code is attached to this issue.
The data files are coming from my software which is all written in .Net and when outputting in UTF-8 the default behaviour of .Net is to include the BOM at the start of the file. The BOM is not required for UTF-8 but it is not forbidden so I think this should be fixed (if possible) for future releases. I will be modifying my software so that output of the BOM can be disabled by my users if desired
Looking at the error message given I expect that the same problem would also affect N3 files since they are using the same reader afaict from the error trace.