I'm trying to write a program that reads a file of an array (arranged with the Rows as the first character, and the Columns as the next character, and then a box of RxC terms) and tries to determine if five characters next to each other horizontally, vertically, or either way diagonally are the same, to color differently (in my GUI main program)
The code is EXTREMELY slow, and only works for smaller arrays? I don't understand what I'm doing wrong.
The Files look like this:
5 4
1 2 3 4 5
1 2 3 4 5
7 3 2 0 1
6 1 2 3 5
Code:
public class fiveinarow
{
int[][] Matrix = new int [100][100];
byte[][] Tag = new byte [100][100];
int row, col;
String filepath, filename;
public fiveinarow()
{
row = 0;
col = 0;
filepath = null;
filename = null;
}
public void readfile()
{
JFileChooser chooser = new JFileChooser();
chooser.setDialogType(JFileChooser.OPEN_DIALOG );
chooser.setDialogTitle("Open Data File");
int returnVal = chooser.showOpenDialog(null);
if( returnVal == JFileChooser.APPROVE_OPTION)
{
filepath = chooser.getSelectedFile().getPath();
filename = chooser.getSelectedFile().getName();
}
try
{
Scanner inputStream = new Scanner(new FileReader(filepath));
int intLine;
row = scan.nextInt();
col = scan.nextInt();
for (int i=0; i < row; i++)
{
for (int j = 0 ; j < col; j++)
{
int[][]Matrix = new int[row][col];
Matrix[i][j] = inputStream.nextInt();
}
}
}
catch(IOException ioe)
{
System.exit(0);
}
}
When I compute a 7x7, I get confirmation of opening and processing gives an array (7x7) of all Zeroes. When I compute a 15x14, I get "Exception in thread "AWT-EventQueue-0" errors and no array when processed.