简体   繁体   English

Jena RDF文件解析问题

[英]Jena RDF file parsing issue

Am trying to parse a simple rdf file using InputStream. 我正在尝试使用InputStream解析一个简单的rdf文件。 I will have a huge file to read, so I need to reading it from input stream. 我将要读取一个大文件,因此需要从输入流中读取它。

My code : 我的代码:

public static void main(String args[]) throws Exception{

        String file = "/Users/rdf_files/testRDF.rdf";

        InputStream in = new FileInputStream(file);

        if (in == null) {
            System.out.println("file not found");
        }

        Model model = ModelFactory.createDefaultModel();
        model.read(in, null);
        model.write(System.out);


        System.out.println("read the file");
    }

My file : 我的档案:

<?xml version="1.0"?>

<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:cd="http://www.recshop.fake/cd#">

<rdf:Description
rdf:about="http://www.recshop.fake/cd/Empire Burlesque">
  <cd:artist>test 1</cd:artist>
  <cd:country>USA</cd:country>
  <cd:company>Columbia</cd:company>
  <cd:price>10.90</cd:price>
  <cd:year>1985</cd:year>
</rdf:Description>

<rdf:Description
rdf:about="http://www.recshop.fake/cd/Hide your heart">
  <cd:artist>test 2</cd:artist>
  <cd:country>UK</cd:country>
  <cd:company>CBS Records</cd:company>
  <cd:price>9.90</cd:price>
  <cd:year>1988</cd:year>
</rdf:Description>

</rdf:RDF>

I am getting exception like : 我正在像这样的异常:

java.lang.ClassNotFoundException: com.ibm.icu.text.StringPrepParseException

Can anyone tell me what am doing wrong? 谁能告诉我做错了什么?

slm,我遇到了同样的问题,我通过在我的classPath中添加“ com.ibm.icu_3.4.4.1.jar”来解决它,希望对您有所帮助:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM