1
我想新的節點添加到我的RDF文件,我第一次提出的文件我寫的東西,如:如何使用Apache Jena在RDF文檔中編寫新節點?
String eventosURI = "http://Eventos";
String path = getServletContext().getRealPath("/") + "DataBase/Events.xml";
Model base = ModelFactory.createDefaultModel();
Resource node = base.createResource(eventosURI).addProperty(VCARD.NAME, something);
try{
FileOutputStream fos = new FileOutputStream(path);
base.write(fos);
} catch(Exception e){
out.println(e.getMessage());
}
但後來我不得不更多的節點添加到同一個文件,如果我叫同servlet重新創建模型並覆蓋其他節點。
我嘗試改變與此FileOutputStream中:
FileWriter write = new FileWriter(path, true);
base.write(write);
這工作,但不是我想要的,因爲再寫整個結構......有什麼辦法已經創建的節點添加到RDF的方式嗎?
你的意思是你想從原始文件到內存中加載模型,一些數據添加到內存模型,然後寫模型恢復到文件中? –
或者,如果您以N-Triples格式序列化數據,則可以通過將輸出發送到文件來將更多數據添加到文件。 –