當前位置: 首頁>>代碼示例>>Java>>正文


Java Model.write方法代碼示例

本文整理匯總了Java中org.apache.jena.rdf.model.Model.write方法的典型用法代碼示例。如果您正苦於以下問題:Java Model.write方法的具體用法?Java Model.write怎麽用?Java Model.write使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.jena.rdf.model.Model的用法示例。


在下文中一共展示了Model.write方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: get

import org.apache.jena.rdf.model.Model; //導入方法依賴的package包/類
@Override
public RESTResource get(URI uri, Map<String, String> parameters) throws RESTException {
	RESTResource resource = new RESTResource(uri.toString(),this);

	Dataset dataset = ThingDirectory.get().dataset;
	dataset.begin(ReadWrite.READ);

	try {
		Model result = dataset.getNamedModel(uri.toString());
		if (!result.isEmpty()) {
			resource.contentType = "text/turtle";
			ByteArrayOutputStream out = new ByteArrayOutputStream();
			result.write(out, "Turtle");
			resource.content = out.toString();
		} else {
			throw new RESTException();
		}
	} finally {
		dataset.end();
	}
	
	return resource;
}
 
開發者ID:thingweb,項目名稱:thingweb-directory,代碼行數:24,代碼來源:VocabularyHandler.java

示例2: main

import org.apache.jena.rdf.model.Model; //導入方法依賴的package包/類
public static void main(String[] args) throws IOException {
PropertyConfigurator.configure("log4j.info");
BufferedReader reader = new BufferedReader(new FileReader(args[0]));
FileOutputStream out = new FileOutputStream(new File("/usr/local/RAID/geonames.nt"));
String buffer = null;
int count = 0;

while ((buffer = reader.readLine()) != null) {
    if (++count % 2 == 0) {
	logger.debug("processing xml: " + buffer);
	Model model = ModelFactory.createDefaultModel() ;
	model.read(new StringReader(buffer), null, "RDF/XML");
	model.write(out, "N-TRIPLE");
    } else {
	logger.info("skipping: " + buffer);
    }
}
reader.close();
   }
 
開發者ID:ld4l-labs,項目名稱:linked_data_authorities,代碼行數:20,代碼來源:Loader.java

示例3: writeToDisk

import org.apache.jena.rdf.model.Model; //導入方法依賴的package包/類
private void writeToDisk(URI uri, Model model){
	logger.debug("Writing model for " + uri + "to disk.");
	
	File cacheFile = getCacheFile(uri);
	
	try (OutputStream os = new BufferedOutputStream(new FileOutputStream(cacheFile))) {
		model.write(os, cacheFileLanguage.getLabel());
	} catch (IOException e) {
		logger.error("Could not write to disk.", e);
	}
}
 
開發者ID:dice-group,項目名稱:RDF2PT,代碼行數:12,代碼來源:URIDereferencer.java


注:本文中的org.apache.jena.rdf.model.Model.write方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。