Did you tried lastIndexOf() and deleteCharAt() of StringBuffer?
Try something like this :
int lastComma = replacement.lastIndexOf(",");
replacement.deleteCharAt(lastComma) ;
For more info, Go through this http://java.sun.com/javase/6/docs/api/java/lang/StringBuffer.html
Hope this helps!