import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
import javax.swing.JOptionPane;


public class ImgClass {
//
	double[][] imgMatrix = ReadMatrix();
//

	
	public double[][] ReadMatrix() {
		String filename = JOptionPane.showInputDialog("Enter The file to be read");
		File fl = new File(filename);
		double matrix[][] = new double[0][0];
		try {
			Scanner fn = new Scanner(fl);
			int row = 0;
			while (fn.hasNext()) {
				row ++;
				fn.nextLine();
			}
			fn.close();
			matrix = new double[row][];
			Scanner f2 = new Scanner(fl);
			row = 0;
			while (f2.hasNext()) {
				String line = f2.nextLine();
				System.out.println(line);
				String[] numarr = line.split(" ");
				int x = numarr.length;
				double[] arr = new double[x];
				matrix[row]= arr;
				for (int i = 0; i<numarr.length;i++){
					matrix[row][i] = Double.parseDouble(numarr[i]);
				}
				row++;
			}
			f2.close();
	    } catch (FileNotFoundException e) {
	        System.out.println("Error opening file. Please make sure that you have your text file in the same folder as the NumFiles.class");
	        System.exit(0);
	    }
		return matrix;
	}

	public int[][] cleanup() {
//...
	}

	public String FindBestMatch() {
	//...
	}
	public double compareMatrices( int[][] num) {
	//...
	}
}
