Java - Write code to trim Suffix

Requirements

Write code to trim Suffix

Demo

//package com.book2s;

public class Main {
    public static void main(String[] argv) {
        String text = "book2s.com";
        String suffix = "com";
        System.out.println(trimSuffix(text, suffix));
    }/*from  w  ww .j a  va2 s .c  om*/

    public static final String trimSuffix(final String text,
            final String suffix) {
        if (text == null) {
            return null;
        }
        if (suffix == null) {
            return text;
        }
        if (text.endsWith(suffix)) {
            return text.substring(0, text.length() - suffix.length());
        }
        return text;
    }
}