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 x, String z)
Ends With
return x.endsWith(z);
booleanendsWith(String[] endsWith, String line)
return true if line ends with something in the array
for (String s : endsWith) {
    if (line.endsWith(s)) {
        return true;
return false;
booleanendsWith(String[] searchStrings, String text)
Returns whether the text ends with one of the given search strings.
for (int i = 0; i < searchStrings.length; i++) {
    if (text.endsWith(searchStrings[i]))
        return true;
return false;
intendsWith(String[] searchStrings, String text)
Returns the index of the longest search string with which the given text ends or -1 if none matches.
int index = -1;
for (int i = 0; i < searchStrings.length; i++) {
    if (text.endsWith(searchStrings[i])) {
        if (index == -1 || searchStrings[i].length() > searchStrings[index].length())
            index = i;
return index;
...
booleanendsWith(StringBuffer buf, String s)
ends With
int iBuf = buf.length();
int iS = s.length();
while (--iS >= 0 && --iBuf >= 0 && buf.charAt(iBuf) == s.charAt(iS)) {
return iS < 0;
booleanendsWith(StringBuffer buffer, String suffix)
Checks that a string buffer ends up with a given string.
if (suffix.length() > buffer.length()) {
    return false;
int endIndex = suffix.length() - 1;
int bufferIndex = buffer.length() - 1;
while (endIndex >= 0) {
    if (buffer.charAt(bufferIndex) != suffix.charAt(endIndex)) {
        return false;
...
booleanendsWith(StringBuffer in, String ending)

Returns true if the StringBuffer parameter ends with the ending String.

return (in.length() >= ending.length() && (in.substring(in.length() - ending.length()).equals(ending)));
booleanendsWith(StringBuilder sb, String end)
ends With
int i = sb.indexOf(end, sb.length() - end.length());
return i != -1;
booleanendsWith(StringBuilder sb, String s)
ends With
int len = s.length();
if (sb.length() < len) {
    return false;
for (int i = sb.length() - len, j = 0; j < len; i++, j++) {
    if (sb.charAt(i) != s.charAt(j)) {
        return false;
return true;
booleanendsWith(StringBuilder sb, String suffix)
Tests if this StringBuilder ends with the specified suffix.
return startsWith(sb, suffix, sb.length() - suffix.length());