如何使用java实现Apache Jena格式的RDF/XML?

内容来源于 Stack Overflow,并遵循CC BY-SA 3.0许可协议进行翻译与使用

  • 回答 (1)
  • 关注 (0)
  • 查看 (128)

以下是我使用的代码:

String synonyms =null;
Property hasSynonyms=null;
String hasSynonymStr="hasSynonyms";
hasSynonyms =model1.createProperty(hasSynonymStr);
try {
        File file1 = new File("Data/9606.protein.aliases.v10.5.txt");
        FileReader fileReader1 = new FileReader(file1);
        BufferedReader bufferedReader1 = new BufferedReader(fileReader1);
        StringBuffer stringBuffer = new StringBuffer();
        String line1;
        System.out.println("Proteins & Synonyms:");
        int count = 0;
        while ((bufferedReader1.readLine()) != null) {
                line1 = bufferedReader1.readLine();
                String[] list1 = line1.split("\t");

                proteinG=model1.createResource(ProtURI+list1[0]);
                hasSynonyms=model1.createProperty(hasSynonymStr);
                synonyms=model1.expandPrefix(list1[0]);
                proteinG.addProperty(hasSynonyms,synonyms); 

输出:

<https://Bio2cv.net/9606.ENSP00000348838> <hasSynonyms> "9606.ENSP00000348838” .
提问于
用户回答回答于

可将以下代码:

    while ((bufferedReader1.readLine()) != null) {
            line1 = bufferedReader1.readLine();

改为:

    while ((line1 = bufferedReader1.readLine()) != null) {

扫码关注云+社区

领取腾讯云代金券