java.lang.ArrayIndexOutOfBoundsException: 2
我想知道这个异常是什么意思,并且如何修改,谢谢
import java.awt.*;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.event.*;
import java.io.*;
import jxl.*;
public class Test {
JFrame frame=new JFrame("");
public Test() {
JButton b1=new JButton("open");
b1.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
final JFileChooser fc=new JFileChooser();
int value=fc.showOpenDialog(null);
try{
if(value==JFileChooser.APPROVE_OPTION){
String filename=null;
String fileddirectory=null;
String file_and_directoryname=null;
filename=fc.getSelectedFile().getName();
fileddirectory=fc.getCurrentDirectory().toString();
file_and_directoryname=fileddirectory+"/"+filename;
try{
InputStream is=new FileInputStream(file_and_directoryname);
Workbook rwb = Workbook.getWorkbook(is);
rwb.getNumberOfSheets();
Sheet st = rwb.getSheet("Sheet1");
int Rows=st.getRows();
int Cols=st.getColumns();
System.out.println("当前工作表的名字:"+st.getName());
System.out.println("总行数:"+Rows);
System.out.println("总列数:"+Cols);
String [] columnNames={"本机号码","类型","对方号码","对方姓名","起始时间",
"时长(分钟)","通话类型"};
Cell c;
String [][] str=new String[Rows+1][Cols+1];
for(int i=0;i
}
}
rwb.close();
}
catch(Exception ex){
ex.printStackTrace();
}
}
}
catch(Exception ex){
}
}
});
Container cp=frame.getContentPane();
cp.setLayout(new FlowLayout());
cp.add(b1);
frame.setSize(300,200);
frame.setVisible(true);
}
public static void main(String []args){
new Test();
}
}