anchor.diff:  catch (RDFHandlerException e) {
     // handle a problem encountered by the RDFHandler
   }
  -----
  -
  +finally {
  +  inputStream.close();
  +}
  +----
  +
  
positive.code: ----
  Model model; // a collection of several RDF statements
  FileOutputStream out = new FileOutputStream("/path/to/file.rdf")
  Rio.write(myGraph, out, RDFFormat.RDFXML);
  ----
  
  Since we have now seen how to read RDF using a parser and how to write using a writer, we can now convert RDF files from one syntax to another, simply by using a parser for the input syntax, collecting the statements, and then writing them again using a writer for the intended output syntax. However, you may notice that this approach may be problematic for very large files: we are collecting all statements into main memory (in a Model object).
  
negative.code: [source,java,linenum]
  ----
  Model results = Rio.parse(inputStream, documentUrl.toString(), RDFFormat.TURTLE);
  ----
  
  == Iterating through all the triples in a file
  
  RDF files can also be parsed in a background thread and iterated through as a query result. This allows files
  that are too big to fit into memory (at once) to be parsed sequentially using a familiar API (specifically, the
  {javadoc}query/GraphQueryResult.html[GraphQueryResult] interface).
  
  Using the same Turtle file from above:
  [source,java,linenum]
  ----
  java.net.URL documentUrl = new URL("http://example.org/example.ttl");
  InputStream inputStream = documentUrl.openStream();
  ----
  
  We now have an open `InputStream` to our RDF file. Instead of using a parser directly, we can use
  the {javadoc}query/QueryResults.html[QueryResults].parseGraphBackground() function:
  
  [source,java,linenum]
  ----
  String baseURI = documentUrl.toString();
  RDFFormat format = RDFFormat.TURTLE;
  try (GraphQueryResult res = QueryResults.parseGraphBackground(inputStream, baseURI, format)) {
    while (res.hasNext()) {
      Statement st = res.next();
      // ... do something with the resulting statement here.
    }
  }
  catch (RDF4JException e) {
    // handle unrecoverable error
  }
  finally {
    inputStream.close();
  }
  ----
  
  == Using your own RDFHandler: counting statements
  