Java code to get all nmers of a substring 07-25-2014d1116

2015-01-13

Java code to get all nmers of a substring 07-25-2014d1116

public ArrayList getAllNMersOfString(String the_string, int size_of_nmer)

ArrayList return_list = new ArrayList();

boolean end_of_string_reached = false;
int starting_index_count = 0;
int ending_index_count = size_of_nmer;
while(!end_of_string_reached)
{
if(ending_index_count>the_string.length())
{
end_of_string_reached = true;

else

return_list.add(the_string.substring(starting_index_count, ending_index_count));
starting_index_count++;
ending_index_count++;
if(ending_index_count>the_string.length())
{
end_of_string_reached = true;

}
}

return return_list;
}