java.lang.ArrayIndexOutOfBoundsException: 1错误
下面程序实现一个从文件中读取信息插如数据库的功能.
单独测试插入数据库没有问题,但是从文件中读取时老报java.lang.ArrayIndexOutOfBoundsException: 1的错误.
public class TransferMgr
{
/**
* 空构造函数
*/
public TransferMgr()
{
}
public void UpdateTransfer()
{
BufferedReader reader;
TransferInfoDaoMysql transferInfoDaoMysql=new TransferInfoDaoMysql();
try
{
reader = new BufferedReader(new FileReader("conf/transfer.log"));
String line;
while((line=reader.readLine())!=null)
{
TransferInfo info=new TransferInfo(line);//这行出错.调用的下面的类.
transferInfoDaoMysql.transInsert(info);
}
System.out.println("quit while");
reader.close();
}
catch (IOException e)
{
e.printStackTrace();
}
catch (DAORuntimeException ex)
{
ex.printStackTrace();
}
}
}
/**
* 用字符串初始化一条传输记录
* @param transfer
*/
public TransferInfo(String transfer)
{
String[] files=new String[3];
files=transfer.split(" ");
this.fileName=files[0];
System.out.println(files[1]);
this.Size=Long.parseLong(files[1]);
this.transfer_Time=files[2];
String[] file=fileName.split("_");
this.CacheID=file[0];
this.ChannelID=file[1];
this.date=file[2];
}