catch(Exception e){
System.err.println("Error: Target File Cannot Be Read");
}
Any developer writing this code should be immediately fired.
Never catch an Exception
, but perform proper and specific error handling. Catch the most precise error to handle (e.g. FileNotFoundException
), avoid catching errors that you do not know how to handle. If in doubt, rethrow the error, so that an outer error handler can process it. Always log the error, unless it is expected to happen.
Then you would be getting a more precise error message. But you opted to ignore the actual error e
.
REALLY REALLY read a Java book or tutorial, in particular the section on proper exception handling. You are making your own live difficult by discarding the error the way you have been doing it.
An exception is almost never something you should ignore. You are required to handle them for a reason! (In fact, there are also "unchecked" exception, where you are not required to do so. Which makes it even more obvious that here, you need to handle them properly.)
Three Rules for Effective Exception Handling (java.net)
Your error most likely is an ArrayOutOfBoundsException
(which you should not have caught!)
double[][] x = new double[180][1];
double[][] y = new double[180][0];
this is too small. you probably need
double[][] x = new double[180][2];
double[][] y = new double[180][1];