1 7 package jena.examples.rdf ; 8 9 import com.hp.hpl.jena.rdf.model.*; 10 import com.hp.hpl.jena.util.FileManager; 11 import com.hp.hpl.jena.vocabulary.*; 12 13 import java.io.*; 14 15 20 public class Tutorial07 extends Object { 21 22 static final String inputFileName = "vc-db-1.rdf"; 23 24 public static void main (String args[]) { 25 Model model = ModelFactory.createDefaultModel(); 27 28 InputStream in = FileManager.get().open(inputFileName); 30 if (in == null) { 31 throw new IllegalArgumentException ( "File: " + inputFileName + " not found"); 32 } 33 34 model.read( in, ""); 36 37 ResIterator iter = model.listSubjectsWithProperty(VCARD.FN); 39 if (iter.hasNext()) { 40 System.out.println("The database contains vcards for:"); 41 while (iter.hasNext()) { 42 System.out.println(" " + iter.nextResource() 43 .getRequiredProperty(VCARD.FN) 44 .getString() ); 45 } 46 } else { 47 System.out.println("No vcards were found in the database"); 48 } 49 } 50 } 51 52 78 | Popular Tags |