int numRows = 0;
int rowCountShowProgress = 0;
int numFields = -1;
try {
FileInputStream in = new FileInputStream(csvFile);
CSVParse shredderRowCount = getParser(in);
while ((line = shredderRowCount.getLine()) != null) {
if (numFields == -1) {
numFields = line.length;
} else {
if (numFields != line.length) {
resultMessage.append("Failed row=" + (numRows + 1) + " : All rows must have the same number of Fields" + "\n");
workDialog.dispose();
in.close();
return resultMessage;
}
}
numRows++;
}
in.close();
if (numRows == 0) {
resultMessage.append("The file is empty");
workDialog.dispose();
return resultMessage;
}
FileInputStream in2 = new FileInputStream(csvFile);
CSVParse shredder = getParser(in2);
line = shredder.getLine();
//add two extra fields for the isDebt/Amount conversion
String[] expandedLine = new String[line.length + 2];
for (int k = 0; k < line.length; k++) {
expandedLine[k] = line[k];
}
expandedLine[line.length] = "";
expandedLine[line.length + 1] = "";
v.add(expandedLine);
try {
act_id = ((Integer) (formatNumPane.numPanels[formatNumPane.SHOW_INTEGER]
.parse(line[tableMatchedIndexes[INDEX_ACT_ID]]))).intValue();
} catch (Exception e) {
resultMessage.append("Failed row=" + rowCount + " : Cannot continue processing this file. Bad transaction number found="
+ line[tableMatchedIndexes[tableMatchedIndexes[INDEX_ACT_ID]]] + "\n");
workDialog.dispose();
in2.close();
return resultMessage;
}
do {
rowCount++;
rowCountShowProgress++;
if (rowCountShowProgress >= 10) {
workDialog.SetProgress(rowCount * 100 / numRows);
rowCountShowProgress = 0;
}
line = shredder.getLine();
if (line != null) {
try {
act_id_test = ((Integer) (formatNumPane.numPanels[formatNumPane.SHOW_INTEGER]
.parse(line[tableMatchedIndexes[INDEX_ACT_ID]]))).intValue();
} catch (Exception e) {