请问如何将通过读取文件得到的字符串信息,进行分割后得到的字符数组的部分字符信息,给存入到非字符数组中去!比如整数数组和浮点数数组!希望能得到解答!谢谢!
public void MenuId() throws IOException {
@SuppressWarnings("resource")
BufferedReader br = new BufferedReader(new FileReader("menu.txt"));
br.readLine();
String str;
int i=0;
int[] idArray=new int[]{};
int[] id=new int[4];
while((str=br.readLine())!=null){
idArray=str.split("\\s+");
for(int j=0;j<3;j++) {
if(j==0) {
id[i]=idArray[j];
i++;}
if(i==4) break;
}
}
}
代码报错问题:就是说数组类型匹配不了,无法传递字符串数组的信息到整数数组