br.close();
return rows;
}
public ActionResult importFile(File selectedFile) throws IOException {
Timer timer = new Timer();
forceKey = dt.getImporterForceKey();
BufferedReader br = new BufferedReader(new FileReader(selectedFile));
int colcount = 0;
TreeMap<String,Stats> types = new TreeMap<String,Stats>();
for(String line=br.readLine(); line!=null; line=br.readLine()){
Vector<String> cols = parseLine(line, getSeparator());
colcount = Math.max(colcount,cols.size());
String key = cols.get(0);
if (forceKey) {
key = "" + (rowKey++);
}
Stats stats = new Stats(key);
if (forceKey) {
stats.vals.add(cols.get(0));
}
for(int i=1; i<cols.size(); i++){
stats.vals.add(cols.get(i));
}
types.put(key, stats);
}
Object[][] details = (forceKey) ? new Object[colcount+1][5] : new Object[colcount][5];
if (forceKey) {
details[0][0] = String.class;
details[0][1] = "Col0";
details[0][2] = 100;
details[0][4] = false;
for(int i=0; i<colcount; i++) {
details[i+1][0] = String.class;
details[i+1][1] = "Col" + (i+1);
details[i+1][2] = 100;
details[i+1][4] = true;
}
} else {
for(int i=0; i<colcount; i++) {
details[i][0] = String.class;
details[i][1] = "Col" + i;
details[i][2] = 100;
details[i][4] = true;
}
}
return new ActionResult(selectedFile, selectedFile.getName(), this.toString(), details, types, true, timer.getDuration());
}