我正在尝试将文件读入二维数组。当我在第一部分读到它时,这些值是正确的。当我把它写出来时,这些值都是“10”。我怎样才能解决这个问题?
public static void readagain() {
try {
InputStream is = new FileInputStream("C:\\test.new");
int m = 16;
int n = 16;
int[][] a = new int[m][n];
int value=0;
while ((value = is.read()) != -1) {
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
try{
a[i][j] = value;
System.out.println("number is "+ a[i][j]);
}
catch (Exception e) {
e.printStackTrace();
}
}//j
} //i
}
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
System.out.println("number is "+a[i][j]);
}
}
}
catch (Exception e) {
e.printStackTrace();
}
}