Package systole.exceptions

Examples of systole.exceptions.ExceptionIO


    public FileWriterSystlole(String fileName) throws ExceptionIO {
        try {
            this.writer = new BufferedWriter(new FileWriter(fileName));
        } catch (IOException ex) {
            SystoleLogger.getInstance().logError(ex.getMessage());
            throw new ExceptionIO(ex.getMessage());
        }
    }
View Full Code Here


                //FileWriter always assumes default encoding is OK!
                this.writer.write(line);

            } catch (IOException ex) {
               SystoleLogger.getInstance().logError(ex.getMessage())
               throw new ExceptionIO(ex.getMessage());
            }
        }
   }
View Full Code Here

     */
    @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);
        }

    }
View Full Code Here

    @Override
  public Segment readFile(String path) throws ExceptionIO {

        if (path == null) {
            throw new ExceptionIO("Path inválido");
        }
        Segment points = new Segment();
        String cadena = "";
        BigDecimal value;
        int currentLine = 1;
        try {
            this.fileReader = new FileReader(path);
            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: " + path + " 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);
        }
    }
View Full Code Here

TOP

Related Classes of systole.exceptions.ExceptionIO

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.