Java String Ends With endsWith(String str, String end, boolean caseSensitive)

Here you can find the source of endsWith(String str, String end, boolean caseSensitive)

Description

ends With

License

Open Source License

Declaration

public static boolean endsWith(String str, String end, boolean caseSensitive) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static boolean endsWith(String str, String end, boolean caseSensitive) {
        if (str == null || end == null) {
            return (str == null && end == null);
        }//from w ww  . j  av a  2 s . com
        if (end.length() > str.length()) {
            return false;
        }

        int offset = str.length() - end.length();
        return str.regionMatches(caseSensitive, offset, end, 0, end.length());
    }
}

Related

  1. endsWith(String s1, String s2)
  2. endsWith(String source, String target, boolean caseSensitive)
  3. endsWith(String str, char c)
  4. endsWith(String str, char suffix)
  5. endsWith(String str, char suffix)
  6. endsWith(String str, String mark)
  7. endsWith(String str, String suffix)
  8. endsWith(String str, String suffix)
  9. endsWith(String str, String suffix, boolean ignoreCase)