- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我编写了一个将数据转换为 RDF 的函数,我需要将此 RDF 上传到 fusioni 服务器。
我尝试实现 here 中的代码如下
public class GenerateRDF {
public void setRDF(String[] personalData ) {
String serviceURI = "http://localhost:3030/Date";
DatasetAccessorFactory factory = null;
DatasetAccessor accessor;
accessor = factory.createHTTP(serviceURI);
String name = personalData[0];
String nationality = personalData[1];
String date = personalData[2];
String address = personalData[3];
String mobile = personalData[4];
String email = personalData[5];
String website = personalData[6];
String profesional = personalData[7];
String education = personalData[8];
String communication = personalData[9];
String digital = personalData[10];
String professional = personalData[11];
String management = personalData[12];
String certifications = personalData[13];
InputStream in = null;
Model model = ModelFactory.createDefaultModel();
Resource node = model.createResource(personURI)
.addProperty(FOAF.name, name)
.addProperty(FOAF.member, nationality)
.addProperty(FOAF.birthday, date)
.addProperty(FOAF.homepage, address)
.addProperty(FOAF.phone, mobile)
.addProperty(FOAF.yahooChatID, email)
.addProperty(FOAF.weblog, website)
.addProperty(FOAF.plan, profesional)
.addProperty(FOAF.knows, education)
.addProperty(FOAF.depiction, communication)
.addProperty(FOAF.interest, digital)
.addProperty(FOAF.publications, professional)
.addProperty(FOAF.maker, management)
.addProperty(FOAF.made, certifications);
String base = "http://test-projects.com/";
model.read(in, base, "RDF/XML");
accessor.putModel(model);
model.write(System.out);
}
}
返回以下异常:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at java.io.FilterInputStream.read(Unknown Source) at org.apache.xerces.impl.XMLEntityManager$RewindableInputStream.readAndBuffer(Unknown Source) at org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown Source) at org.apache.xerces.impl.XMLEntityManager.startEntity(Unknown Source) at org.apache.xerces.impl.XMLEntityManager.startDocumentEntity(Unknown Source) at org.apache.xerces.impl.XMLDocumentScannerImpl.setInputSource(Unknown Source) at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source) at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source) at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source) at com.hp.hpl.jena.rdf.arp.impl.RDFXMLParser.parse(RDFXMLParser.java:151) at com.hp.hpl.jena.rdf.arp.ARP.load(ARP.java:119) at org.apache.jena.riot.lang.LangRDFXML.parse(LangRDFXML.java:142) at org.apache.jena.riot.RDFParserRegistry$ReaderRIOTFactoryImpl$1.read(RDFParserRegistry.java:142) at org.apache.jena.riot.RDFDataMgr.process(RDFDataMgr.java:760) at org.apache.jena.riot.RDFDataMgr.read(RDFDataMgr.java:258) at org.apache.jena.riot.RDFDataMgr.read(RDFDataMgr.java:244) at org.apache.jena.riot.adapters.RDFReaderRIOT.read(RDFReaderRIOT.java:69) at com.hp.hpl.jena.rdf.model.impl.ModelCom.read(ModelCom.java:274) at GenerateRDF.setRDF(GenerateRDF.java:59) at PersonalInfo$2.actionPerformed(PersonalInfo.java:251) at javax.swing.AbstractButton.fireActionPerformed(Unknown Source) at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source) at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source) at javax.swing.DefaultButtonModel.setPressed(Unknown Source) at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source) at java.awt.Component.processMouseEvent(Unknown Source) at javax.swing.JComponent.processMouseEvent(Unknown Source) at java.awt.Component.processEvent(Unknown Source) at java.awt.Container.processEvent(Unknown Source) at java.awt.Component.dispatchEventImpl(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Window.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.EventQueue.dispatchEventImpl(Unknown Source) at java.awt.EventQueue.access$500(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source) at java.awt.EventQueue$4.run(Unknown Source) at java.awt.EventQueue$4.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.run(Unknown Source)
有办法修复这个错误吗?我愿意接受解决方案...
最佳答案
您可能想看看这里:https://hub.docker.com/r/stain/jena-fuseki/
有一个关于数据加载的部分可以指导您。
更具体地说,可以在这里找到 load.sh 和 tdbloader:https://github.com/stain/jena-docker/tree/master/jena-fuseki
我对你的问题有点困惑,因为你在标题中提到“将文件上传到fuseki”,但你的代码没有引用任何文件......
关于java - 如何使用Java将RDF代码上传到fuseki服务器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43101265/
我是一名优秀的程序员,十分优秀!