1 package at.ac.tuwien.lsdc.util;
3 import java.io.FileReader;
4 import java.io.FileWriter;
5 import java.io.IOException;
8 import au.com.bytecode.opencsv.CSVReader;
9 import au.com.bytecode.opencsv.CSVWriter;
11 public class CSVHandler {
12 private final String filename;
14 public CSVHandler(String filename) {
15 this.filename = filename;
18 public List readFile() throws IOException {
19 CSVReader reader = new CSVReader(new FileReader(filename));
20 return reader.readAll();
23 public void writeFile(List data) throws IOException {
24 CSVWriter writer = new CSVWriter(new FileWriter(filename), '\t');
25 writer.writeAll(data);
29 public void writeLine(String[] data) throws IOException {
30 CSVWriter writer = new CSVWriter(new FileWriter(filename), '\t');
31 writer.writeNext(data);