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 16 21 public class Tutorial08 extends Object { 22 23 static final String inputFileName = "vc-db-1.rdf"; 24 25 public static void main (String args[]) { 26 Model model = ModelFactory.createDefaultModel(); 28 29 InputStream in = FileManager.get().open(inputFileName); 31 if (in == null) { 32 throw new IllegalArgumentException ( "File: " + inputFileName + " not found"); 33 } 34 35 model.read( in, "" ); 37 38 StmtIterator iter = model.listStatements( 41 new 42 SimpleSelector(null, VCARD.FN, (RDFNode) null) { 43 public boolean selects(Statement s) { 44 return s.getString().endsWith("Smith"); 45 } 46 }); 47 if (iter.hasNext()) { 48 System.out.println("The database contains vcards for:"); 49 while (iter.hasNext()) { 50 System.out.println(" " + iter.nextStatement() 51 .getString()); 52 } 53 } else { 54 System.out.println("No Smith's were found in the database"); 55 } 56 } 57 } 58 59 85 | Popular Tags |