Home > Database > Mysql Tutorial > body text

【Sesame】导出已经存在的三元组数据

WBOY
Release: 2016-06-07 15:28:42
Original
1460 people have browsed it

在Sesame系列上一篇介绍了如何添加三元组数据,本文将介绍如何导出三元组数据到文件。 1. 建立数据库连接 static NativeStore nativeStore;static Repository repo;static String rdfFile;static {rdfFile = exportTemp.ttl;repoFile = new File(ldbc);nativ

在Sesame系列上一篇介绍了如何添加三元组数据,本文将介绍如何导出三元组数据到文件。

1. 建立数据库连接

	static NativeStore nativeStore;
	static Repository repo;
	static String rdfFile;
	static {
		rdfFile = "exportTemp.ttl";
		repoFile = new File("ldbc");
		nativeStore = new NativeStore(repoFile);
		repo = new SailRepository(nativeStore);
	}
Copy after login

2. 初始化数据库连接

	public static void databaseInitialize() {
		try {
			repo.initialize();
		} catch (RepositoryException e) {
			e.printStackTrace();
		}
	}
Copy after login

3. 导出数据

	public static void outputDatabase(String filename) {
		try {
			FileOutputStream out = new FileOutputStream(filename);
			RDFWriter writer = Rio.createWriter(RDFFormat.TURTLE, out);
			RepositoryConnection newConn = repo.getConnection();
			newConn.export(writer);
		} catch (RepositoryException e) {
			e.printStackTrace();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (RDFHandlerException e) {
			e.printStackTrace();
		}
		System.out.println("-------Output ends--------");
	}
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!