Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

public class Main {
    /**
     * Removes suffix string of String parameter and returns it back, otherwise returns null if suffix is invalid i.e. doesn't exist at the end like a suffix should
     * @param stringToTrimSuffixOf
     * @param suffixStringToRemove
     * @return
     */
    public static String sansSuffixOfString(String stringToTrimSuffixOf, String suffixStringToRemove) {
        if (stringToTrimSuffixOf.endsWith(suffixStringToRemove)) {
            return stringToTrimSuffixOf.substring(0, stringToTrimSuffixOf.length() - suffixStringToRemove.length());
        } else {
            return null;
        }
    }
}