You will need to implement this function yourself. You could use something like:
package com.example.stringutils;
import java.util.ArrayList;
public class Util {
/** Return a list of all the indexes of the 'key' string that occur in the
* 'arbitrary' string. If there are none an empty list is returned.
*
* @param key
* @param arbitrary
* @return
*/
private static ArrayList<Integer> allIndexesOf(String key, String arbitrary) {
ArrayList<Integer> result = new ArrayList<Integer>();
if (key == null | key.length() == 0 | arbitrary == null | arbitrary.length()<key.length()) {
return result;
}
int loc = -1;
while ((loc = arbitrary.indexOf(key, loc+1)) > -1) {
result.add(loc);
}
return result;
}
}
You may want to see if regular expressions actually perform faster (fewer code lines aren't always faster, just simpler "code").