本文整理匯總了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;
}
示例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();
}
示例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);
}
}