"Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 49, Size: 49"
comes when you are trying to access array number that is not defined.
ex.
Array arr[5];
print(arr[6]);//[color=#FF0000:dqfhkbzi] java.lang.IndexOutOfBoundsException comes here[/color:dqfhkbzi]
string splitting there is function you have to use called "substring"
http://www.javatpoint.com/substring