class StringUtilities {

    public static String trimBoth(String input, char trimmableChar)
    {
        if (input == null)
        {
            return null;
        }

        int len = input.length();
        int st = 0;
        char[] val = input.toCharArray();

        while (st < len && val[st] == trimmableChar)
        {
            st++;
        }
        while (st < len && val[len - 1] == trimmableChar)
        {
            len--;
        }
        return st > 0 || len < input.length() ? input.substring(st, len) : input;
    }

    private  StringUtilities();

}