-1
我在特定文件中有n個cols和m個行我怎麼能但每個列都在不同的數組中? *行列數的數量是可變讀取數據並將每個列存儲在不同的數組中
String readline = null;
readline = read.readLine();
String[] getlength = readline.split(" ");
cols = getlength.length;
while (readline != null) {
readline = read.readLine();
rows++;
}
// Array of data
int[][] data = new int[rows][cols];
// New bufferedReader to put the cursor on the top of the file
read = new BufferedReader(new FileReader("1.txt"));
// for loop to skip first three rows
for (int i = 1; i <= 3; i++) {
read.readLine();
}
// to set the file Data into the array
String line = null;
line = read.readLine();
do {
readData = line.split(" ");
for (int j = 0; j < readData.length; j++) {
data[indexx][j] = Integer.parseInt(readData[j]);
}
indexx++;
line = read.readLine();
} while (line != null);