I am trying to extract a substring of a specified index from a line for each loop. Here is the string:
String allPins = "16101702000000 376627817243
16101702000001 326520924472
16101702000000 376627817243
16101702000001 326520924472
16101702000000 376627817243
16101702000001 326520924472
16101702000000 376627817243
16101702000001 326520924472
16101702000000 376627817243
16101702000001 326520924472
16101702000000 376627817243
16101702000001 326520924472
16101702000000 376627817243
16101702000001 326520924472
16101702000000 376627817243
16101702000001 326520924472
16101702000000 376627817243
16101702000001 326520924472
16101702000000 376627817243
16101702000001 326520924472";
It is not an array of type string. The first 14 digits is the batch number. I want extract the second 12-digit number, i.e. pin number as a substring everytime I loop through the string.
here is my code so far:
for (int i = 0; i < allPins.length();i++){
String str = allPins.substring((28*i)+15,(28*i)+28);
String test = str;
System.out.println(test);
}
//I am getting an outOfBoundError.
//Please help me out on how to best extract the substrings.