I cannot, for the life of me, figure out how to deal with this exception. I have included the code below but my basic problem is that when I call next in the Iterator and try to cast it as int I get this error. I have tried several ways to do it but all result in the same exception - help!
The Code: public class CSVFile {
static Matrix m; static int leng; static int locationCount; static double maxDistance;
public static void main(String[] args) throws IOException {
leng = args[0].length();
// Construct a new CSV parser. CSV csv = new CSV(); BufferedReader is = new BufferedReader(new FileReader(args[0])); process(csv, is); PatchBuilder landscape = new PatchBuilder(); double intervalSize = Double.parseDouble(args[1]); double numberOfClasses = (maxDistance/intervalSize); for (int a=0;a<numberOfClasses;a++) { double thresholdDistance = a*intervalSize; landscape.BuildGraph(thresholdDistance); System.out.println(thresholdDistance+","+landscape.averageClusterSize); } }
m = new Matrix(new double[leng][leng]); while ((line = is.readLine()) != null) { System.out.println("line = `" + line + "'"); Iterator e = csv.parse(line); while (e.hasNext()) x = ((Integer)e.next()).intValue(); y = ((Integer)e.next()).intValue(); double dist = Double.parseDouble(e.next().toString()); m.set(x,y,dist);
} locationCount = m.getRowDimension(); for (int a=0;a<locationCount;a++) { for (int b=0;b<locationCount;b++) { double maxDistance = 0; if (m.get(a,b)>maxDistance) { maxDistance = m.get(a,b); } } } } }