jtable添加数据,老是添加的不对,如下图
最后发现时读取的数据拆分不正确,"|"是特殊字符,不能作为regx拆分string,所以split("|")不起作用
还有变量的作用域也很特别,如下代码
while((str=bfr.readLine())!=null){
Vector rowData = new Vector();
System.out.println("str:"+str);
String[] string=new String[6];
string = str.split(",");
System.out.println("length:"+string.length);
for(int l=0;l<string.length;l++){
rowData.add(string[l].trim());
}
tableModel.addRow(rowData);
System.out.println(rowData.get(3));
}
//Vector rowData = new Vector();如果这句话写在while外面就不好用了,这样只能添加一次数据