Java Utililty Methods String Ends With

List of utility methods to do String Ends With

Description

The list of methods to do String Ends With are organized into topic(s).

Method

booleanendsWith(byte[] bytes, String str)
ends With
if (bytes.length < str.length())
    return false;
int actualByteCount = bytes.length;
while ((actualByteCount > 0)
        && ((bytes[actualByteCount - 1] == '\n') || (bytes[actualByteCount - 1] == '\r')))
    actualByteCount--;
if (actualByteCount < str.length())
    return false;
...
booleanendsWith(byte[] dataFrom, String suffix)
ends With
for (int i = 1; i <= suffix.length(); i++) {
    int dfOffset = dataFrom.length - i;
    int suffixOffset = suffix.length() - i;
    if (dataFrom[dfOffset] != suffix.charAt(suffixOffset)) {
        return false;
return true;
...
booleanendsWith(byte[] source, char c)
ends With
return endsWith(source, new byte[] { (byte) c });
booleanendsWith(byte[] subject, byte[] suffix)
Returns true if subject ends with suffix .
int start = subject.length - suffix.length;
if (start < 0) {
    return false;
for (int i = start; i < subject.length; i++) {
    if (subject[i] != suffix[i - start]) {
        return false;
return true;
booleanendsWith(char s[], int len, char suffix[])
Returns true if the character array ends with the suffix.
final int suffixLen = suffix.length;
if (suffixLen > len)
    return false;
for (int i = suffixLen - 1; i >= 0; i--)
    if (s[len - (suffixLen - i)] != suffix[i])
        return false;
return true;
booleanendsWith(char[] fieldDescriptor, char c)
ends With
if (fieldDescriptor.length == 0) {
    return false;
return fieldDescriptor[fieldDescriptor.length - 1] == c;
booleanendsWith(CharSequence cs, CharSequence suffix)
Tests if a char sequence ends with some suffix
return startsWith(cs, suffix, (cs.length() - suffix.length()));
booleanendsWith(CharSequence cs, String postfix)
Returns whether cs ends with postfix.
boolean match;
int sbLen = cs.length();
int pLen = postfix.length();
if (sbLen >= pLen) {
    match = true;
    for (int p = pLen - 1, s = sbLen - 1; match && p >= 0; p--, s--) {
        match = postfix.charAt(p) == cs.charAt(s);
} else {
    match = false;
return match;
booleanendsWith(CharSequence s, char c)
Determine if the string s ends with the char c .
int len = s.length();
return len > 0 && s.charAt(len - 1) == c;
booleanendsWith(CharSequence s, char c)
ends With
if (s == null)
    return false;
int len = s.length();
if (len == 0)
    return false;
return s.charAt(len - 1) == c;