java.lang.ArrayIndexOutOfBoundsException 을 당신이 액세스 할 때이java.lang.ArrayIndexOutOfBoundsException 처리-7하는 방법
public static void main(String[] args) throws ClassNotFoundException, SQLException {
FileUpdate obj = new FileUpdate();
obj.run();
}
public void run() throws SQLException, ClassNotFoundException {
String csvFile = "/home/IMRAN/file.csv";
BufferedReader br = null;
String line = "";
String cvsSplitBy = ",";
try {
DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
Date dateobj = new Date();
String dt = df.format(dateobj);
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/Rforms", "root", "root12");
Statement st = con.createStatement();
br = new BufferedReader(new FileReader(csvFile));
while ((line = br.readLine()) != null) {
String[] emp = line.split(cvsSplitBy);
// if (emp[0] != null && emp[1] != null) {
// for(int x = 0; x < emp.length; x++) {
String t = (String) emp[0].trim();
String t2 = (String) emp[1].trim();
}
}
어제 나 오늘 같은 질문을 던졌다고 생각합니다. 나는 같은 질문을 한 다음 csv 파일 내용을 다시 붙여 넣으라는 질문을 할 것입니다. – SMA
0 ~ arr.length -1 외부의 잘못된 index number.means를 가진 배열 객체에 액세스 중임 –
배열에 접근하기 전에 배열의 길이를 확인하십시오. 'emp [0]','emp [1]'etc –