01: /*
02: * (c) Copyright 2003, 2004, Hewlett-Packard Development Company, LP
03: * All rights reserved.
04: * [See end of file]
05: * $Id: Tutorial09.java,v 1.3 2005/10/06 17:49:05 andy_seaborne Exp $
06: */
07: package jena.examples.rdf;
08:
09: import com.hp.hpl.jena.rdf.model.*;
10: import com.hp.hpl.jena.util.FileManager;
11:
12: import java.io.*;
13:
14: /** Tutorial 9 - demonstrate graph operations
15: *
16: * @author bwm - updated by kers/Daniel
17: * @version Release='$Name: $' Revision='$Revision: 1.3 $' Date='$Date: 2005/10/06 17:49:05 $'
18: */
19: public class Tutorial09 extends Object {
20:
21: static final String inputFileName1 = "vc-db-3.rdf";
22: static final String inputFileName2 = "vc-db-4.rdf";
23:
24: public static void main(String args[]) {
25: // create an empty model
26: Model model1 = ModelFactory.createDefaultModel();
27: Model model2 = ModelFactory.createDefaultModel();
28:
29: // use the class loader to find the input file
30: InputStream in1 = FileManager.get().open(inputFileName1);
31: if (in1 == null) {
32: throw new IllegalArgumentException("File: "
33: + inputFileName1 + " not found");
34: }
35: InputStream in2 = FileManager.get().open(inputFileName2);
36: if (in2 == null) {
37: throw new IllegalArgumentException("File: "
38: + inputFileName2 + " not found");
39: }
40:
41: // read the RDF/XML files
42: model1.read(in1, "");
43: model2.read(in2, "");
44:
45: // merge the graphs
46: Model model = model1.union(model2);
47:
48: // print the graph as RDF/XML
49: model.write(System.out, "RDF/XML-ABBREV");
50: System.out.println();
51: }
52: }
53:
54: /*
55: * (c) Copyright 2003, 2004 Hewlett-Packard Development Company, LP
56: * All rights reserved.
57: *
58: * Redistribution and use in source and binary forms, with or without
59: * modification, are permitted provided that the following conditions
60: * are met:
61: * 1. Redistributions of source code must retain the above copyright
62: * notice, this list of conditions and the following disclaimer.
63: * 2. Redistributions in binary form must reproduce the above copyright
64: * notice, this list of conditions and the following disclaimer in the
65: * documentation and/or other materials provided with the distribution.
66: * 3. The name of the author may not be used to endorse or promote products
67: * derived from this software without specific prior written permission.
68: *
69: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
70: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
71: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
72: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
73: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
74: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
75: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
76: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
77: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
78: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
79: */
|