With Jena it is not so difficult:
Given a file rdfexample.ntriple containing the following RDF in N-TRIPLE form (example taken from here): "1988" . "9.90" . "CBS Records" . "UK" . "Bonnie Tyler" . "1985" . "10.90" . "Columbia" . "USA" . "Bob Dylan" .
the following code public static void main(String[] args) { String fileNameOrUri = "src/a/rdfexample.ntriple"; Model model = ModelFactory.createDefaultModel(); InputStream is = FileManager.get().open(fileNameOrUri); if (is != null) { model.read(is, null, "N-TRIPLE"); model.write(System.out, "TURTLE"); } else { System.err.println("cannot read " + fileNameOrUri);; } }
reads the file, and prints it out in TURTLE form: "Bonnie Tyler" ; "CBS Records" ; "UK" ; "9.90" ; "1988" . "Bob Dylan" ; "Columbia" ; "USA" ; "10.90" ; "1985" .
So, with Jena you can easily parse RDF (in any form) into a com.hp.hpl.jena.rdf.model.Model object, which allows you to programmatically manipulate it.