Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Jena库没有将输出写入外部RDF/XML文件_Java_File Io_Jena - Fatal编程技术网

Java Jena库没有将输出写入外部RDF/XML文件

Java Jena库没有将输出写入外部RDF/XML文件,java,file-io,jena,Java,File Io,Jena,我对我的耶拿图书馆的写作方法有意见。 我有下面一段代码,它应该在外部文件中写入输出,但它没有这样做 import com.hp.hpl.jena.rdf.model.*; import com.hp.hpl.jena.vocabulary.*; import com.hp.hpl.jena.rdf.model.impl.ModelCom; public class Tutorial04 extends Object { // some definitions static String t

我对我的耶拿图书馆的写作方法有意见。 我有下面一段代码,它应该在外部文件中写入输出,但它没有这样做

import com.hp.hpl.jena.rdf.model.*;
import com.hp.hpl.jena.vocabulary.*;
import com.hp.hpl.jena.rdf.model.impl.ModelCom;


public class Tutorial04 extends Object {

// some definitions
static String tutorialURI  = "http://hostname/rdf/tutorial/";
static String briansName   = "Brian McBride";
static String briansEmail1 = "brian_mcbride@hp.com";
static String briansEmail2 = "brian_mcbride@hpl.hp.com";
static String title        = "An Introduction to RDF and the Jena API";
static String date         = "23/01/2001";

@SuppressWarnings("unused")
public static void main (String args[]) {

    // some definitions
    String personURI    = "http://somewhere/JohnSmith";
    String givenName    = "John";
    String familyName   = "Smith";
    String fullName     = givenName + " " + familyName;
    // create an empty model
    Model model = ModelFactory.createDefaultModel();

    // create the resource
    //   and add the properties cascading style
    Resource johnSmith
      = model.createResource(personURI)
             .addProperty(VCARD.FN, fullName)
             .addProperty(VCARD.N,
                          model.createResource()
                               .addProperty(VCARD.Given, givenName)
                               .addProperty(VCARD.Family, familyName));

    // now write the model in XML form to a file
  //  model.write(System.out, "RDF/XML");
    model.write(System.out,"RDF/XML");
}
}您有:

model.write(System.out,"RDF/XML");
上面写着“请将此模型的内容写入标准输出”,即不写入任何命名文件。要将模型写入文件,您需要说明哪个文件:

String fileName = "your_file_name_here.rdf";
FileWriter out = new FileWriter( fileName );
try {
    model.write( out, "RDF/XML-ABBREV" );
}
finally {
   try {
       out.close();
   }
   catch (IOException closeException) {
       // ignore
   }
}

谢谢你,伊恩:)这很有帮助。此外,我还需要你在我的最后一年的项目更多的帮助。你也有耶拿图书馆的知识吗?很高兴它对你有帮助。如果您需要有关Jena的其他帮助,您可以继续在此处提问或向Jenu用户组发布消息:请参阅Hi Ian。能告诉我你的电子邮件地址吗?本周我将在耶拿的一些任务上需要帮助。费萨尔,通过电子邮件向耶拿提问的最好地方是我在上一次评论中提到的耶拿用户列表。你会得到整个社区的人的帮助,而不仅仅是一个人。另外,你的问题和他们得到的答案可能会帮助其他人。