即時嘗試從文件創建矩陣,該文件是這樣的: 其中我的第一行的大小爲矩陣= 10 x 9 而在其他行中,我們有15個價值分佈是偶然的。如何從文件讀取數組
3 5
4 5 6
12 34 12 12 8
34 23
12 34 34 10 89
隨着信息大小我將定義我的matriz。我用這種方法閱讀:
public static void read(){
String line= "";
int i = 0;
try {
while((line = bf.readLine()) != null){
if (i == 0){
//Call method that get the size and create my global matriz
}else{
String[] list = line.split(" ");
//I need help here, for insert correctly in the array
}
i++;
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
我怎麼能在矩陣中插入有序?我的矩陣應該是這樣的:
4 5 6 12 34
12 12 8 34 23
12 34 34 10 89
任何想法?