you're never going into the while loop that is supposed to enter the numbers in your arrays.
take a look at
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.Scanner;
public class Test1 {
public static void main(String[] args) {
Scanner key = new Scanner(System.in);
System.out.println("Enter the name of the file: ");
String name = key.next();
Scanner inputStream = null;
try {
File nn = new File(name);
System.out.println(nn.getAbsolutePath());
inputStream = new Scanner(new FileInputStream(name));
} catch (FileNotFoundException e) {
System.out.println("File" + name + " is not found!");
System.out.println("or couldn't be opened!");
System.exit(0);
}
int size = 0;
if (inputStream.hasNext()) {
size = inputStream.nextInt();
inputStream.nextLine();
inputStream.nextLine();
} else {
System.out.println("The Size of the matrix is not clearly stated!");
}
int array[][] = new int[size][size];
while (inputStream.hasNextInt()) {
System.out.println("ran");
for (int i = 0; i < array.length; i++) {
for (int j = 0; j < array[i].length; j++) {
if (inputStream.hasNextInt()) {
array[i][j] = inputStream.nextInt();
// inputStream.next();
}
}
}
}
inputStream.close();
for (int i = 0; i < array.length; i++) {
for (int j = 0; j < array[i].length; j++) {
System.out.print(array[i][j]);
System.out.print(" ");
}
System.out.println();
}
}
} , test this and explain to us why I've made those changes and why they are changing your output.