*/
@Override
public Segment readFile(File file) throws ExceptionIO {
if (file == null) {
throw new ExceptionIO("Archivo inálido");
}
Segment points = new Segment();
String cadena = "";
BigDecimal value;
int currentLine = 1;
try {
this.fileReader = new FileReader(file);
BufferedReader bf = new BufferedReader(this.fileReader);
while ((cadena = (bf.readLine())) != null) {
value = new BigDecimal(new Double(cadena),MathUtils.CONTEXT);
points.add(value);
currentLine++;
}
this.fileReader.close();
return points;
} catch (IOException e) {
SystoleLogger.getInstance().logInfo("Error on read file, Msg: " + e.getMessage());
throw new ExceptionIO("No se pudo leer el archivo");
} catch (NumberFormatException n) {
SystoleLogger.getInstance().logInfo("Error on read line: " + cadena + " Msg: " + n.getMessage());
try {
this.fileReader.close();
} catch (IOException e) {
SystoleLogger.getInstance().logInfo("Error on close file, msg: " + e.getMessage());
}
throw new ExceptionIO("Error al leer la línea " + currentLine);
}
}