Java - Write code to trim Trailing White Space from a StringBuilder

Requirements

Write code to trim Trailing White Space from a StringBuilder

Demo

//package com.book2s;

public class Main {
    public static void main(String[] argv) {
        StringBuilder innerBody = new StringBuilder();
        innerBody.append("abc  ");
        trimTrailingWhiteSpace(innerBody);
    }/*  w w  w . jav  a 2s.  co  m*/

    /**
     * @param innerBody
     */
    public static void trimTrailingWhiteSpace(StringBuilder innerBody) {
        while (Character
                .isWhitespace(innerBody.charAt(innerBody.length() - 1))) {
            innerBody.deleteCharAt(innerBody.length() - 1);
        }
    }
}