I am trying to create a swear word parser, i keep running
into a memory error..
public static String sanitize(String str)
{
String upper = str.toUpperCase();
int index=0;
for (int i=0; i<SWEAR.length; i++)
{
while((index = upper.indexOf(SWEAR[i].toUpperCase())) >=
0)
{
str = replace(str, index, SWEAR[i].length(),
CLEAN);
}
}
return str;
}
private static String replace(String str, int index, int len,
String curse)
{
StringBuffer buf = new StringBuffer(str.length());
buf.append(str.substring(0));
buf.append(curse);
buf.append(str.substring(index+len));
return buf.toString();
}