code: private Stream<Quad> fetchAllFromGraph(final String fromGraphName, final IRI toGraphName) {
          final Query q = new Query();
          q.setQuerySelectType();
          q.addResultVar(SUBJECT);
          q.addResultVar(PREDICATE);
          q.addResultVar(OBJECT);
  
          final ElementPathBlock epb = new ElementPathBlock();
          epb.addTriple(create(SUBJECT, PREDICATE, OBJECT));
  
          final ElementGroup elg = new ElementGroup();
          elg.addElement(new ElementNamedGraph(createURI(fromGraphName), epb));
  
          q.setQueryPattern(elg);
  
          final Stream.Builder<Quad> builder = builder();
          rdfConnection.querySelect(q, qs -> builder.accept(rdf.createQuad(toGraphName,
                          getSubject(qs), getPredicate(qs), getObject(qs))));
          return builder.build();
      }
docs: This code is equivalent to the SPARQL query below.
  
  <p><pre><code>
  SELECT ?subject ?predicate ?object
  WHERE { GRAPH fromGraphName { ?subject ?predicate ?object } }
  </code></pre>