KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jena > examples > rdf > Tutorial05


1 /*
2  * (c) Copyright 2003, 2004, Hewlett-Packard Development Company, LP
3  * All rights reserved.
4  * [See end of file]
5  * $Id: Tutorial05.java,v 1.1 2005/03/12 13:52:28 andy_seaborne Exp $
6  */

7 package jena.examples.rdf ;
8
9 import com.hp.hpl.jena.rdf.model.*;
10 import com.hp.hpl.jena.util.FileManager;
11
12 import java.io.*;
13
14 /** Tutorial 5 - read RDF XML from a file and write it to standard out
15  *
16  * @author bwm - updated by kers/Daniel
17  * @version Release='$Name: $' Revision='$Revision: 1.1 $' Date='$Date: 2005/03/12 13:52:28 $'
18  */

19 public class Tutorial05 extends Object JavaDoc {
20
21     /**
22         NOTE that the file is loaded from the class-path and so requires that
23         the data-directory, as well as the directory containing the compiled
24         class, must be added to the class-path when running this and
25         subsequent examples.
26     */

27     static final String JavaDoc inputFileName = "vc-db-1.rdf";
28                               
29     public static void main (String JavaDoc args[]) {
30         // create an empty model
31
Model model = ModelFactory.createDefaultModel();
32
33         InputStream in = FileManager.get().open( inputFileName );
34         if (in == null) {
35             throw new IllegalArgumentException JavaDoc( "File: " + inputFileName + " not found");
36         }
37         
38         // read the RDF/XML file
39
model.read(new InputStreamReader(in), "");
40                     
41         // write it to standard out
42
model.write(System.out);
43     }
44 }
45
46 /*
47  * (c) Copyright 2003, 2004 Hewlett-Packard Development Company, LP
48  * All rights reserved.
49  *
50  * Redistribution and use in source and binary forms, with or without
51  * modification, are permitted provided that the following conditions
52  * are met:
53  * 1. Redistributions of source code must retain the above copyright
54  * notice, this list of conditions and the following disclaimer.
55  * 2. Redistributions in binary form must reproduce the above copyright
56  * notice, this list of conditions and the following disclaimer in the
57  * documentation and/or other materials provided with the distribution.
58  * 3. The name of the author may not be used to endorse or promote products
59  * derived from this software without specific prior written permission.
60  *
61  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
62  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
63  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
64  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
65  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
66  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
67  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
68  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
69  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
70  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
71  */

72
Popular Tags