Android String Remove removeSuffix(String str, String suffix)

Here you can find the source of removeSuffix(String str, String suffix)

Description

remove Suffix

Declaration

public static String removeSuffix(String str, String suffix)
        throws Exception 

Method Source Code

//package com.java2s;

public class Main {

    public static String removeSuffix(String str, String suffix)
            throws Exception {
        if (null == str)
            return null;
        if ("".equals(str.trim()))
            return "";

        if (null == suffix || "".equals(suffix))
            return str;

        if (str.endsWith(suffix)) {
            return str.substring(0, str.length() - suffix.length());
        }/*  w  w  w . ja  v a  2 s .c om*/

        throw new Exception(str + " ????????" + suffix
                + "??");
    }

    public static String subString(String str, int length) {
        if (isBlank(str)) {
            return "";
        } else if (str.length() > length) {
            return str.substring(0, length);
        } else {
            return str;
        }
    }

    public static boolean isBlank(String str) {
        if (null == str)
            return true;
        if ("".equals(str.trim()))
            return true;

        return false;
    }

    public static boolean isBlank(Long str) {
        if (null == str)
            return true;
        return false;
    }
}

Related

  1. removeAccents(String string)
  2. removeBackslashes(String content)
  3. removeDuplicates(String[] first, String[] second)
  4. removeSpace(String str)
  5. removeWhitespace(String str)
  6. rmvSpace(String baseStr)
  7. rmvSpecial(String baseStr)
  8. removeBlanks(String content)