From: Arun R. <rao...@gm...> - 2009-12-09 09:37:45
|
Hi, I was trying to read a TRIG file multiple times into memory and then write it back without making changes and I ran into errors with the parser. Here is the sample code: String filename = "test.trig"; NamedGraphSet graphSet = new NamedGraphSetImpl(); NamedGraphModel ngModel = new NamedGraphModel(graphSet, ""); InputStream in = FileManager.get().open(filename); if (in == null) { throw new IllegalArgumentException("File: not found"); } graphSet.read(in, "TRIG", null); try { ngModel.write(new PrintWriter(new File(filename)), "TRIG"); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } test.trig: @prefix ns0: <http://example.com/> . <http://graph1.com/> {ns0:aResource ns0:pProperty ns0:bResource ; ns0:qProperty ns0:xResource . } The first run, it creates an extra line: <> {} in the TRIG file The second run, it creates an extra line: <null> {} in the TRIG file The third run fails. If however, I change: graphSet.read(in, "TRIG", null); to: graphSet.read(in, "TRIG", ""); it works fine. What could be the issue? Is this a bug? Regards, Arun |