weyns49570 / efficient-java-matrix-library

Automatically exported from code.google.com/p/efficient-java-matrix-library
0 stars 0 forks source link

MatrixIO.loadCSV() does not check the input data #30

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hello,

In the following code:

 try
            {
                numRows = Integer.parseInt(rowsJTextField.getText());
                numCols = Integer.parseInt(columnsJTextField.getText());
            } catch (NumberFormatException numberFormatException)
            {
                JOptionPane.showMessageDialog(rootPane, numberFormatException.getMessage(), "Problem with the conversion", JOptionPane.ERROR_MESSAGE);
            }
            try
            {
                dataset = MatrixIO.loadCSV(dataSetFileName, numRows, numCols);
            } catch (Exception ex)
            {
                JOptionPane.showMessageDialog(rootPane, ex.getMessage(), "I cannot load the file: " + datasetFile.getName(), JOptionPane.ERROR_MESSAGE);
                return;
            }

If I enter number of rows greater than the number that the file actually 
contains then the ex.getMessage() returns null.
If instead of Exception I use IOException I cannot caught the exception - a 
NullPointerException is thrown

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at org.ejml.ops.ReadMatrixCsv.read(Unknown Source)
    at org.ejml.ops.MatrixIO.loadCSV(Unknown Source)
    at ipapas.mlj.MainFrame.loadFileJButtonActionPerformed(MainFrame.java:396)
    at ipapas.mlj.MainFrame.access$000(MainFrame.java:47)
If I enter number of rows less then the number that the file actually contains 
then no Exception is thrown.

regards,
Ioannis P.

Original issue reported on code.google.com by peter.ab...@gmail.com on 7 Dec 2012 at 11:19

GoogleCodeExporter commented 9 years ago

Original comment by peter.ab...@gmail.com on 17 Jan 2013 at 11:41