final File outputFile) throws TweetStoreException, MalformedQueryException, SailException, QueryEvaluationException, IOException {
OutputStream out = new FileOutputStream(outputFile);
PrintStream ps = new PrintStream(out);
try {
TweetStoreConnection c = store.createConnection();
try {
ParsedQuery q = parseQuery(SELECT_DUMP_FIELDS);
BindingSet bs = new MapBindingSet();
SailConnection sc = c.getSailConnection();
try {
sc.begin();
CloseableIteration<? extends BindingSet, QueryEvaluationException> results
= sc.evaluate(q.getTupleExpr(), q.getDataset(), bs, false);
try {
while (results.hasNext()) {
BindingSet r = results.next();
String timestamp = ((Literal) r.getBinding(TIMESTAMP).getValue()).getLabel().replaceAll("\t", " ");
String location = ((Literal) r.getBinding(LOCATION).getValue()).getLabel().replaceAll("\t", " ");
String text = ((Literal) r.getBinding(TEXT).getValue()).getLabel()
.replaceAll("\t", " ")
.replaceAll("\n", " ")
.replaceAll("\r", " ");
ps.println(timestamp + "\t" + location + "\t" + text);
}
} finally {
results.close();
}
} finally {
sc.rollback();
sc.close();
}
} finally {
c.close();
}
} finally {
out.close();
}
}