You can use a function like this for the same
String[] ret = new String[16];
//default capacity. Using a java util class and then converting to
String[]
//should be a better idea instead of allocation of memory at the start.
int len = token.length();
int i = 0 ;
for(int j = 0, k = 0; k != -1; j = k + len)
{
k = str.indexOf(token, j);
String tempStr = str.substring(j, k == -1 ? str.length() :
k).trim();
if(tempStr.length() > 0 ){
ret[i] = tempStr;
i++;
}
}