简体   繁体   中英

Jena RDF file parsing issue

Am trying to parse a simple rdf file using InputStream. 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”来解决它,希望对您有所帮助:)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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