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(final CharSequence str, final CharSequence suffix)
ends With
return endsWith(str, 0, str.length(), suffix);
booleanendsWith(final CharSequence target, final CharSequence suffix)
ends With
if (target == null || suffix == null) {
    return false;
if (target == suffix) {
    return true;
final int suffixLength = suffix.length();
final int targetLength = target.length();
...
booleanendsWith(final Object[] left, final Object[] right, final boolean equals)
Tests whether the first array ends with the second array.
if (left == null || right == null) {
    return false;
int l = left.length;
int r = right.length;
if (r > l || !equals && r == l) {
    return false;
for (int i = 0; i < r; i++) {
    if (!equals(left[l - i - 1], right[r - i - 1])) {
        return false;
return true;
booleanendsWith(final String path, final String suffix)
Returns whether or not the provided path ends in the provided suffix.
return path != null && !path.trim().isEmpty() && path.toLowerCase().endsWith(suffix);
booleanendsWith(final String s, final String suffix, final boolean ignoreCase)

Check if a String ends with a specified suffix (optionally case insensitive).

if (s == null || suffix == null) {
    return s == null && suffix == null;
if (suffix.length() > s.length()) {
    return false;
final int strOffset = s.length() - suffix.length();
return s.toString().regionMatches(ignoreCase, strOffset, suffix.toString(), 0, suffix.length());
...
booleanendsWith(final String src, final String... suffixes)
Test to see if a given string ends with some suffixes.
int pos = src.length();
for (int i = suffixes.length - 1; i >= 0; i--) {
    final String suffix = suffixes[i];
    pos -= suffix.length();
    if (!src.startsWith(suffix, pos)) {
        return false;
return true;
booleanendsWith(final String str, final char suffix)
Check if a String ends with a specified suffix character.
return str != null && str.length() > 0 && str.charAt(str.length() - 1) == suffix;
booleanendsWith(final String str, final String... suffixes)
Nullpointer save version of String.endsWith.
if (str == null || suffixes == null) {
    return false;
for (final String suffix : suffixes) {
    if (str.endsWith(suffix) == true) {
        return true;
return false;
booleanendsWith(final String string, final String[] suffixes)
Checks a string with String#endsWith(String) against an array of candidate strings.
if (isBlank(string) || suffixes == null || suffixes.length == 0) {
    return false;
for (final String suffix : suffixes) {
    if (string.endsWith(suffix)) {
        return true;
return false;
booleanendsWith(final StringBuilder builder, final char match)
Checks to see if a StringBuilder ends with a given character.
if (builder == null) {
    throw new IllegalArgumentException("StringBuilder must not be null");
if (builder.length() == 0) {
    return false;
final char last = builder.subSequence(builder.length() - 1, builder.length()).charAt(0);
return last == match;
...