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(String s, String end)
ends With
if ((s == null) || (end == null)) {
    return false;
if (end.length() > s.length()) {
    return false;
String temp = s.substring(s.length() - end.length(), s.length());
if (temp.equalsIgnoreCase(end)) {
...
booleanendsWith(String s, String end)
ends With
if ((s == null) || (end == null)) {
    return false;
if (end.length() > s.length()) {
    return false;
String temp = s.substring(s.length() - end.length(), s.length());
if (temp.equalsIgnoreCase(end)) {
...
booleanendsWith(String s, String end)
Returns true if the string ends with the string end.
if ((s == null) || (end == null)) {
    return false;
if (end.length() > s.length()) {
    return false;
String temp = s.substring(s.length() - end.length());
if (temp.equalsIgnoreCase(end)) {
...
booleanendsWith(String s, String ending)
ends With
if (ending == null) {
    return true;
if (s == null || s.length() < ending.length()) {
    return false;
return s.substring(s.length() - ending.length()).equals(ending);
booleanendsWith(String s, String suffix)
ends With
if (s == null) {
    return false;
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());
...
booleanendsWith(String s1, String s2)
ends With
if (s1 == null) {
    if (s2 == null) {
        return true;
    } else {
        return false;
} else {
    if (s2 == null) {
...
booleanendsWith(String source, String target, boolean caseSensitive)
ends With
boolean result = false;
if (!isEmpty(source) && !isEmpty(target) && source.length() >= target.length()) {
    if (caseSensitive) {
        result = target.equals(source.substring(source.length() - target.length(), source.length()));
    } else {
        result = target
                .equalsIgnoreCase(source.substring(source.length() - target.length(), source.length()));
return result;
booleanendsWith(String str, char c)
ends With
return str.length() > 0 && str.charAt(str.length() - 1) == c;
booleanendsWith(String str, char suffix)
Tests if this string ends with the specified suffix.
return str != null && str.length() > 0 && str.charAt(str.length() - 1) == suffix;
booleanendsWith(String str, char suffix)
ends With
if (str == null || str.isEmpty())
    return false;
return (str.charAt(str.length() - 1) == suffix);