Advertisement
asanchez75

jena/read/file

Mar 10th, 2016
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. https://github.com/apache/jena/blob/master/jena-arq/src-examples/arq/examples/riot/ExRIOT_6.java
  2.  
  3. package fr.inrialpes.exmo.evolvement;
  4.  
  5. import java.io.BufferedReader;
  6. import java.io.ByteArrayInputStream;
  7. import java.io.File;
  8. import java.io.FileReader;
  9. import java.io.IOException;
  10.  
  11. import com.hp.hpl.jena.rdf.model.Model;
  12. import com.hp.hpl.jena.rdf.model.ModelFactory;
  13. import com.hp.hpl.jena.rdf.model.Statement;
  14. import com.hp.hpl.jena.rdf.model.StmtIterator;
  15.  
  16. public class Reader {
  17.  
  18. public static void main(String[] args) throws IOException {
  19. FileReader in = new FileReader(new File("changeset/removed.nt"));
  20. BufferedReader file = new BufferedReader(in);
  21. String line = "";
  22. int i = 0;
  23. final Model model = ModelFactory.createDefaultModel();
  24. Statement st = null;
  25. while ((line = file.readLine()) != null) {
  26. i++;
  27. Model m = model.read(new ByteArrayInputStream(line.getBytes()), null, "N-TRIPLE");
  28. StmtIterator it = m.listStatements();
  29. while (it.hasNext()) {
  30. st = it.next();
  31. }
  32. System.out.println(st.toString() + "|" + i);
  33. }
  34. }
  35.  
  36.  
  37.  
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement