概述
数组下标越界
package import_csv;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
public class csv_sqlite {
public static void main(String[] args) throws ClassNotFoundException, IOException {
String b[] = { "2012060101", "2012060201", "2012060202", "2012060203",
"2012060204", "2012060205", "2012060206", "2012060207",
"2012060208", "2013010101", "2013010102", "2013010103",
"2013010104", "2013010105", "2013010106", "2013010107",
"2013010108", "2013010201", "2013010202", "2013010203",
"2013010204", "2013010301", "2013010302", "2013020101",
"2013020102", "2013020103", "2013020104", "2013020201",
"2013020202", "2013020203", "2013020204", "2013020301",
"2013020302", "2013030101", "2013030102", "2013030103",
"2013030104", "2013030105", "2013030106", "2013030107",
"2013030108", "2013030109", "2013030110", "2013030111",
"2013030112", "2013030113", "2013030114", "2013030115",
"2013030116", "2013030117", "2013030118", "2013030119",
"2013030120", "2013030121", "2013030122", "2013030123",
"2013030124", "2013030125", "2013030126", "2013030127",
"2013030128", "2013030129", "2013030130", "2013040101",
"2013040102", "2013040103", "2013050101", "2013050102",
"2013050201", "2013050202", "2013050203", "2013050301",
"2013050302", "2013060101", "2013060102", "2013060103",
"2013060104", "2013060105", "2013060106", "2013060201",
"2013060202", "2013060203", "2013060204", "2013060205",
"2013060206", "2013060207", "2013060208", "2013060209",
"2013060210" };
int n = b.length;
System.out.println("数组长度:"+n);
Class.forName("org.sqlite.JDBC");
/*Connection conn = DriverManager
.getConnection("jdbc:sqlite:d:/classtable.db");*/
for (int j = 0; j
String file = "D:\编程\" + b[j] + ".csv";
BufferedReader br = new BufferedReader(new InputStreamReader(
new FileInputStream(file), "GBK"));
String line;
while ((line = br.readLine()) != null) {
String[] value = line.split(",");
String sql = "INSERT INTO [" + b[j] + "] VALUES('" + value[0]
+ "','" + value[1] + "','" + value[2] + "','"
+ value[3] + "','" + value[4] + "')";
System.out.println(sql);
}
br.close();
}
}
}
我想先看看运行出的SQL语句,然后一直提示数组下标越界
以下是运行结果:
数组长度:89
INSERT INTO [2012060101] VALUES('国际贸易实务','实2-205','MON1','8','11')
INSERT INTO [2012060101] VALUES('财政学','教1-315','MON2','8','19')
INSERT INTO [2012060101] VALUES('国际贸易实务','教1-313','MON3','1','11')
INSERT INTO [2012060101] VALUES('中国对外贸易概论','教1-105','MON4','1','9')
INSERT INTO [2012060101] VALUES('广告学概论','教2-106','TUE2','1','15')
INSERT INTO [2012060101] VALUES('国际经济学','教1-206','TUE3','1','15')
INSERT INTO [2012060101] VALUES('外贸英文函电','教1-113','TUE4','1','11')
INSERT INTO [2012060101] VALUES('财政学','教1-315','WED1','8','19')
INSERT INTO [2012060101] VALUES('国际贸易','教1-113','WED3','12','19')
INSERT INTO [2012060101] VALUES('大学英语听说','教1-403','WED4','12','19')
INSERT INTO [2012060101] VALUES('中国对外贸易概论','教1-105','WED4','1','9')
INSERT INTO [2012060101] VALUES('国际贸易实务','教1-313','THU1','1','11')
INSERT INTO [2012060101] VALUES('外贸英文函电','实1-211','THU2','8','11')
INSERT INTO [2012060101] VALUES('外贸英文函电','教1-113','THU3','1','11')
INSERT INTO [2012060101] VALUES('广告学概论','教2-106','THU4','1','15')
INSERT INTO [2012060101] VALUES('国际贸易','教1-113','FRI1','12','19')
INSERT INTO [2012060101] VALUES('大学英语听说','教1-403','FRI2','12','19')
INSERT INTO [2012060101] VALUES('国际经济学','教1-206','FRI3','1','15')
INSERT INTO [2012060201] VALUES('财政学','教2-203','MON2','8','19')
INSERT INTO [2012060201] VALUES('保险学','教2-109','MON3','8','19')
INSERT INTO [2012060201] VALUES('广告学概论','教2-106','TUE1','1','15')
INSERT INTO [2012060201] VALUES('经济法','教1-206','TUE2','8','19')
INSERT INTO [2012060201] VALUES('国际经济学','教1-206','TUE3','1','15')
INSERT INTO [2012060201] VALUES('保险学','教2-109','WED2','8','19')
INSERT INTO [2012060201] VALUES('财政学','教2-203','THU1','8','19')
INSERT INTO [2012060201] VALUES('经济法','教1-206','THU2','8','19')
INSERT INTO [2012060201] VALUES('广告学概论','教2-106','THU3','1','15')
最后
以上就是快乐台灯为你收集整理的java下标越界的三种处理方式,数组下标越界,该怎么解决的全部内容,希望文章能够帮你解决java下标越界的三种处理方式,数组下标越界,该怎么解决所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复