即时尝试从文件创建矩阵,该文件是这样的: 其中我的第一行的大小为矩阵= 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
任何想法?