package ch.tkuhn.hashrdf;

import java.io.FileInputStream;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;

import org.openrdf.model.Statement;
import org.openrdf.rio.helpers.StatementCollector;
import org.openrdf.rio.trig.TriGParser;

public class Test {

	public static void main(String[] args) throws Exception {
		InputStream in = new FileInputStream(args[0]);
		TriGParser p = new TriGParser();
		List<Statement> statements = new ArrayList<>();
		p.setRDFHandler(new StatementCollector(statements));
		p.parse(in, "");
		for (Statement st : statements) {
			System.err.println(st.getContext());
			System.err.println(st.getSubject());
			System.err.println(st.getPredicate());
			System.err.println(st.getObject());
			System.err.println();
		}
	}

}

@@ -67,18 +67,80 @@
 java.io.
-In
+FileOutputStream;%0Aimport java.io.InputStream;%0Aimport java.io.Out
 putStrea
@@ -320,16 +320,56 @@
 GParser;
+%0Aimport org.openrdf.rio.trig.TriGWriter;
 %0A%0Apublic
@@ -526,16 +526,106 @@
 rser();%0A
+%09%09OutputStream out = new FileOutputStream(args%5B1%5D);%0A%09%09TriGWriter w = new TriGWriter(out);%0A
 %09%09List%3CS
@@ -740,16 +740,46 @@
 n, %22%22);%0A
+%09%09in.close();%0A%09%09w.startRDF();%0A
 %09%09for (S
@@ -813,194 +813,63 @@
 %0A%09%09%09
-System.err.println(st.getContext());%0A%09%09%09System.err.println(st.getSubject());%0A%09%09%09System.err.println(st.getPredicate());%0A%09%09%09System.err.println(st.getObject());%0A%09%09%09System.err.println();%0A%09%09%7D
+w.handleStatement(st);%0A%09%09%7D%0A%09%09w.endRDF();%0A%09%09out.close();
 %0A%09%7D%0A

Test reading and writing of TriG files