Java String Ends With EndsWith(String str, String suffix, int strStartPos)

Here you can find the source of EndsWith(String str, String suffix, int strStartPos)

Description

Ends With

License

Creative Commons License

Declaration

public static boolean EndsWith(String str, String suffix, int strStartPos) 

Method Source Code

//package com.java2s;

public class Main {
    public static boolean EndsWith(String str, String suffix, int strStartPos) {
        if (str == null) {
            throw new NullPointerException("str");
        }//from ww w  .  j a  v  a2s  .c o  m
        if (suffix == null) {
            throw new NullPointerException("suffix");
        }
        if (strStartPos < 0) {
            throw new IllegalArgumentException("strStartPos (" + strStartPos + ") is less than " + "0");
        }
        if (strStartPos > str.length()) {
            throw new IllegalArgumentException("strStartPos (" + strStartPos + ") is more than " + str.length());
        }
        int endpos = suffix.length() + strStartPos;
        return (endpos <= str.length())
                && str.substring(strStartPos, (strStartPos) + (endpos - strStartPos)).equals(suffix);
    }
}

Related

  1. endsWith(String str, String end, boolean caseSensitive)
  2. endsWith(String str, String mark)
  3. endsWith(String str, String suffix)
  4. endsWith(String str, String suffix)
  5. endsWith(String str, String suffix, boolean ignoreCase)
  6. endsWith(String string, char character)
  7. endsWith(String string, String... end)
  8. endsWith(String string, String... endsWithText)
  9. endsWith(String value, String[] suffixes)