I have a code like:
projsForWhichPermCheckFailedString = projsForWhichPermCheckFailedSBuilder.substring(0, projsForWhichPermCheckFailedSBuilder.length()-2);
Assuming we are in .NET, If you are appending data separated by a pre-defined delimiter, you can first build your delimited-valued string, using
//choosing "," as the delimiter //strs -> is a IEnumerable<string> you build within your loop string s = string.Join(",", strs);
With the approach above, you are rid of having to remove the last delimiter added...
the result, you can finally append to your string builder instance: