Java examples for java.lang:StringBuilder
remove Chars From StringBuilder End
//package com.java2s; public class Main { public static void main(String[] argv) throws Exception { StringBuilder builder = new StringBuilder(); int charCountToRemove = 2; removeCharsFromEnd(builder, charCountToRemove); }/*from w w w . j a v a 2 s . c om*/ public static void removeCharsFromEnd(StringBuilder builder, int charCountToRemove) { int endIndex = builder.length(); int beginIndex = endIndex - charCountToRemove; beginIndex = beginIndex < 0 ? 0 : beginIndex; builder.delete(beginIndex, endIndex); } }