You have @ in your string I don't see [@] any where, so why are you splitting the string with this token.
Change
String[] str1 = str.split("[@]") to
String[] str1 = str.split("@") For solving indexOutOfBounds:
for (int x = 1; x < str1.length; x++) { String[] st1 = str1 [x].trim().split("\\|"); for (int j = 0; j < st1.length; j++) { System.out.println( j "= " + st1[j].trim()); } }