String queryString = "SELECT * { ?s ?p ?o }";
Query query = QueryFactory.create(queryString);
QueryExecution qexec = QueryExecutionFactory.create(query, model);
try {
ResultSetRewindable results = ResultSetFactory.makeRewindable(qexec.execSelect());
System.out.println("---- XML ----");
ResultSetFormatter.outputAsXML(System.out, results);
results.reset();
System.out.println("---- Text ----");
ResultSetFormatter.out(System.out, results);
results.reset();
System.out.println("\n---- CSV ----");
ResultSetFormatter.outputAsCSV(System.out, results);
results.reset();
System.out.println("\n---- TSV ----");
ResultSetFormatter.outputAsTSV(System.out, results);
results.reset();
System.out.println("\n---- JSON ----");
ResultSetFormatter.outputAsJSON(System.out, results);
results.reset();
} finally {
qexec.close();
}
}