DialogManager.error("CannotRead{0}", fileName);
return null;
}
StringVector sv;
try {
sv = new StringVector();
BufferedInputStream in = file.getBufferedInputStream();
ByteArrayOutputStream line = new ByteArrayOutputStream(102400);
int oldc = 0;
while (true) {
int c = in.read();
if (c < 0) {
break;
}
if (c == '\n' && oldc != '\r') {
//String s = line.toString("ISO-8859-1");
String s = line.toString("Cp1252");
//String str = new String(bytes, "ISO-8859-1");
sv.append(s);
line.reset();
} else {
line.write(c);
}
oldc = c;
}
} catch (Exception e) {
DialogManager.error(e.getMessage());
return null;
}
ArrayModel arr = null;
String[] columnNames = null;
for (String line = sv.firstItem(); line != null; line = sv.nextItem()) {
StringVector tokens = new StringVector(line, ';', false);
if (tokens.size() < 2) {
continue;
}
StructModel s = new StructModel("A");
if (columnNames == null) {
StringVector columnNamesVector = null;
columnNamesVector = tokens;
columnNames = new String[tokens.size()];
int i = 0;
for (i = 0; i < columnNames.length; ++i) {
if (columnNamesVector != null && i < columnNamesVector.size()) {
columnNames[i] = columnNamesVector.getItem(i);
} else {
columnNames[i] = Integer.toString(i);
}
s.append(new StringModel("", columnNames[i]));