Java String Ends With endsWith(String s, String suffix)

Here you can find the source of endsWith(String s, String suffix)

Description

ends With

License

Apache License

Declaration

public static boolean endsWith(String s, String suffix) 

Method Source Code

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

public class Main {
    public static boolean endsWith(String s, String suffix) {
        if (s == null) {
            return false;
        }//  w w  w  .j  a  v a 2s .c  om

        for (int i = s.length() - 1; i >= 0; i--) {
            if (Character.isWhitespace(s.charAt(i))) {
                continue;
            } else {
                return s.regionMatches(i - suffix.length() + 1, suffix, 0, suffix.length());
            }
        }

        return false;
    }
}

Related

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