Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I try to read TTL file and make traversing get subject, predict and object.

the program compile successfully but no output as a result of entering in an infinite call as I understood. any suggestion for help

C#
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package new_try;
 
//import static com.hp.hpl.jena.assembler.JA.Model;
//import com.hp.hpl.jena.graph.Triple;
//import com.hp.hpl.jena.rdf.model.Model;
///*import com.hp.hpl.jena.rdf.model.ModelFactory;*/import java.io.File;
import com.hp.hpl.jena.graph.Triple;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import org.apache.jena.riot.RDFDataMgr;
//import org.apache.jena.riot.RDFDataMgr;
import org.apache.jena.riot.lang.PipedRDFIterator;
import org.apache.jena.riot.lang.PipedRDFStream;
import org.apache.jena.riot.lang.PipedTriplesStream;
 
/**
 *
 * @author bonn
 */
public class New_try {
 
    /**
     * @param args the command line arguments
     * @throws java.io.FileNotFoundException
     */
  
    public static void main(String[] args) throws FileNotFoundException   {
        
  
        final String filename = "E:\\yagoTransitiveType.ttl";
        System.out.println(filename);
        
          System.out.println("Hello1");
          PipedRDFIterator<Triple> iter = new PipedRDFIterator<>();
           final PipedRDFStream<Triple> inputStream = new PipedTriplesStream(iter);
         // PipedRDFStream and PipedRDFIterator need to be on different threads
         ExecutorService executor = Executors.newSingleThreadExecutor();
 //         Create a runnable for our parser thread
        Runnable parser;
        parser = new Runnable() {
           
            @Override
            public void run() {
        System.out.println(filename);
//                 Call the parsing process.
                RDFDataMgr.parse(inputStream, filename);
                
  
            }
        };
//         Start the parser on another thread
        executor.submit(parser);
 
        
        while (iter.hasNext()) {
            Triple next = iter.next();
            System.out.println("Subject:  "+next.getSubject());
            System.out.println("Object:  "+next.getObject());
            System.out.println("Predicate:  "+next.getPredicate());
            System.out.println("\n");
        }


What I have tried:

I used this code . the program is compiled successfully but it does not give any result
Posted
Updated 22-Jul-16 21:26pm
v3

Successful compilation is only a sign of no syntax error. It is not a sign od correctness of the program..

You should learn to use the debugger as soon as possible. Rather than guessing what your code is doing, It is time to see your code executing and ensuring that it does what you expect.

The debugger allow you to follow the execution line by line, inspect variables and you will see that there is a point where it stop doing what you expect.
Debugger - Wikipedia, the free encyclopedia[^]
Mastering Debugging in Visual Studio 2010 - A Beginner's Guide[^]
http://docs.oracle.com/javase/7/docs/technotes/tools/windows/jdb.html[^]
https://www.jetbrains.com/idea/help/debugging-your-first-java-application.html[^]
 
Share this answer
 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900