Remova o char no último índice no buffer de string ou no comprimento da redefinição

sb.setLength(sb.length() - 1);
Amused Angelfish