The following code should replace the last occurrence of a ','
with a ')'
.
StringBuilder b = new StringBuilder(yourString);
b.replace(yourString.lastIndexOf(","), yourString.lastIndexOf(",") + 1, ")" );
yourString = b.toString();
Note This will throw Exceptions if the String
doesn’t contain a ','
.