Edzy_Java

  BlogJava :: 首页 ::  ::  ::  :: 管理 ::
  58 随笔 :: 12 文章 :: 11 评论 :: 0 Trackbacks

//读RDF的程序
import com.hp.hpl.jena.rdf.model.*;
import java.io.*;

public class read-rdf extends Object{

    static final String inputFileName
                           = "i'm-rdf-file.rdf";

    public static void main (Sring args[]){

        try  {

           Model model = ModelFactory.createDefaultModel();

           InputStream in = read-rdf.class
                                    .getClassLoader()
                                    .getResourceAsStream(inputFileName);

           if (in == null) {
               throw new IllegalArgumentException(
                       "file:" + inputFileName +"not found");
             }

           model.read(new InputStreamReader(in), "");

           model.write(System.out);

        }
    }

//写RDF的程序
import com.hp.hpl.jena.rdf.model.*;
import java.io.*;
import com.hp.hpl.jena.xmloutput.*;

public static void main (String args[]){

        String programstype   = "Jena";
        String writername     = "xiaoxiao";
        String things         = "make the program";
        String task           = writername + " " + things;
    
        try{
           Model model = ModelFactory.createDefaultModel()  
         
           Resource xiaoxiao
              = model.createResource(programstype)
                     .addProperty(TASKS, task)
                          model.createResource()
                               .addProterty(WRITER, writername)

             RDFWriter writer = model.getWriter();
             writer.write(model,System.out, null);

            }
}

posted on 2006-11-15 17:05 lbfeng 阅读(214) 评论(0)  编辑  收藏 所属分类: J2SE技术杂谈

只有注册用户登录后才能发表评论。


网站导航: