I do split to a String, but I did not consider the exception. So the error comes out. For example, if the string is "2012-10-21,20:00:00,,"
Here is the codes:
String str = "2012-10-21,20:00:00,,";
String a[] = str.split(",");
String timestamp = a[0] + "T" + a[1];
String temp = a[2];
System.out.println(timestamp);
System.out.println(temp);
Here is the error:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 2
Actually, a[2] is null, but I don't know how to deal with this problem. Because in my String Array, some recodes contains the value of temp, such as "2012-10-21,20:00:00,90,".
Thank you.