@@ -0,0 +1,3155 @@
+/*%0A * Licensed to the Apache Software Foundation (ASF) under one%0A * or more contributor license agreements.  See the NOTICE file%0A * distributed with this work for additional information%0A * regarding copyright ownership.  The ASF licenses this file%0A * to you under the Apache License, Version 2.0 (the%0A * %22License%22); you may not use this file except in compliance%0A * with the License.  You may obtain a copy of the License at%0A *%0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0A%0Apackage arq.examples.riot;%0A%0Aimport java.util.concurrent.ExecutorService;%0Aimport java.util.concurrent.Executors;%0A%0Aimport org.apache.jena.atlas.lib.Sink;%0Aimport org.apache.jena.riot.RDFDataMgr;%0Aimport org.apache.jena.riot.lang.StreamedTriplesIterator;%0Aimport org.apache.jena.riot.out.SinkTripleOutput;%0Aimport org.apache.jena.riot.system.StreamRDF;%0Aimport org.apache.jena.riot.system.StreamRDFBase;%0Aimport org.apache.jena.riot.system.SyntaxLabels;%0A%0Aimport com.hp.hpl.jena.graph.Node;%0Aimport com.hp.hpl.jena.graph.Triple;%0Aimport com.hp.hpl.jena.rdf.model.Property;%0Aimport com.hp.hpl.jena.sparql.vocabulary.FOAF;%0A%0A/** Example of using RIOT : iterate over output of parser run */%0Apublic class ExRIOT_5 %7B%0A    %0A    public static void main(String... argv) %7B%0A        // Not needed here as we are using RIOT itself via RDFDataMgr, not%0A        // indirectly.%0A        // RIOT.init() ;%0A%0A        String filename = %22data.ttl%22;%0A%0A        // Create a StreamedTriplesIterator, this doubles as both a StreamRDF%0A        // for parser output and an iterator for our consumption%0A        // You can optionally supply a buffer size here, see the documentation%0A        // for details about recommended buffer sizes%0A        StreamedTriplesIterator iter = new StreamedTriplesIterator();%0A%0A        // The classes derived from StreamedRDFIterator such as this are%0A        // fully thread safe so the parser and the consumer of the iterator%0A        // may be on different threads%0A        // Generally speaking the parser and the consumer must be on different%0A        // threads as otherwise your consumer code will never start and%0A        // everything will deadlock%0A%0A        ExecutorService executor = Executors.newSingleThreadExecutor();%0A%0A        // Create a runnable for our parser thread%0A        Runnable parser = new Runnable() %7B%0A%0A            @Override%0A            public void run() %7B%0A                // Call the parsing process.%0A                RDFDataMgr.parse(iter, filename);%0A            %7D%0A        %7D;%0A%0A        // Start the parser%0A        executor.submit(parser);%0A%0A        // We will consume the input on the main thread here%0A%0A        // We can now iterate over data as it is parsed, parsing only runs as%0A        // far%0A        // ahead of our consumption as the buffer size allows%0A        while (iter.hasNext()) %7B%0A            Triple next = iter.next();%0A        %7D%0A    %7D%0A%0A%7D%0A

Add source example of using StreamedTriplesIterator