blob: a83a4e94bf035f0b6a1b8426e990a98c9f33fcf5 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
package uk.ac.ox.cs.pagoda.tracking;
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.util.Collection;
import uk.ac.ox.cs.pagoda.query.AnswerTuples;
public class AnswerTuplesWriter {
private static final String QUERY_SEPARATOR = "---------------------------------------------";
BufferedWriter writer = null;
public AnswerTuplesWriter(String fileName) {
try {
writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(fileName)));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
public void write(String[] answerVariables, Collection<String> answerTuples)throws IOException {
for (int i = 0; i < answerVariables.length; ++i)
writer.write(answerVariables[i] + "\t");
writer.newLine();
writer.write(QUERY_SEPARATOR);
writer.newLine();
if (answerTuples == null) {
writer.newLine();
return ;
}
for (String answerTuple: answerTuples) {
writer.write(answerTuple);
writer.newLine();
}
writer.newLine();
}
public void close() {
if (writer != null)
try {
writer.close();
} catch (IOException e) {
e.printStackTrace();
}
}
public void write(String[] answerVariables, AnswerTuples answerTuples) {
// TODO Auto-generated method stub
}
}
|