Ok, I just have one error when I run this. I have code to read in numbers to an array from a file, but I keep getting an error saying "
F:\CS\test3\src\test3\Main.java:24: unreported exception java.lang.Exception; must be caught or declared to be thrown
matrix1 = input(matrix1);"
Here is the code for the method:
public static int[][] input(int[][] a)throws Exception{
int[][] array;
java.io.File file = new java.io.File ("in.dat");
if (!file.exists()){
JOptionPane.showMessageDialog(null, "FILE DNE");
System.exit(0);
}
java.util.Scanner input = new java.util.Scanner(file);
while (input.hasNextInt()){
for (int i = 0; i< a.length; i++){
for (int j=0; j< a[0].length; j++){
array[j] = input.nextInt();
}
}
input.close();
}
return array;
}
This is up in main where I am getting the error:
int[][] matrix1;
int[][] matrix2;
int sixes;
String output = "";
matrix1 = create(5,7);
<matrix1 = input(matrix1);
That is the part giving me an error.
Please help, thanks.
F:\CS\test3\src\test3\Main.java:24: unreported exception java.lang.Exception; must be caught or declared to be thrown
matrix1 = input(matrix1);"
Here is the code for the method:
public static int[][] input(int[][] a)throws Exception{
int[][] array;
java.io.File file = new java.io.File ("in.dat");
if (!file.exists()){
JOptionPane.showMessageDialog(null, "FILE DNE");
System.exit(0);
}
java.util.Scanner input = new java.util.Scanner(file);
while (input.hasNextInt()){
for (int i = 0; i< a.length; i++){
for (int j=0; j< a[0].length; j++){
array[j] = input.nextInt();
}
}
input.close();
}
return array;
}
This is up in main where I am getting the error:
int[][] matrix1;
int[][] matrix2;
int sixes;
String output = "";
matrix1 = create(5,7);
<matrix1 = input(matrix1);
That is the part giving me an error.
Please help, thanks.
