Java Utililty Methods String Suffix

List of utility methods to do String Suffix

Description

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

Method

intsuffix(final String source, final String target)
Find the length of a common suffix.
int pointermin = 0;
int pointermax = Math.min(source.length(), target.length());
int pointermid = pointermax;
while (pointermin < pointermid) {
    if (source.regionMatches(source.length() - pointermid, target, target.length() - pointermid,
            pointermid)) {
        pointermin = pointermid;
    } else {
...
Stringsuffix(String fname)
suffix
int index = fname.lastIndexOf('.');
if (index < 0) {
    return "";
return fname.substring(index + 1).toLowerCase();
Stringsuffix(String input, char delimiter)
Return the remainder of the string after the last occurrence of the delimiter char
if (input == null) {
    return null;
int pos = input.lastIndexOf(delimiter);
if (pos >= 0) {
    if (input.length() > pos + 1) {
        return input.substring(pos + 1);
    } else {
...
Stringsuffix(String mime)
Suggests a file name suffix for the given content type.
switch (mime) {
case "image/png":
    return "png";
case "image/jpeg":
    return "jpg";
case "image/gif":
    return "gif";
default:
...
Stringsuffix(String name, char separator)
Returns the suffix of a String.
if (name == null)
    return null;
int separatorIndex = name.lastIndexOf(separator);
if (separatorIndex < 0 || separatorIndex == name.length() - 1)
    return null;
else
    return name.substring(separatorIndex + 1);
Stringsuffix(String name, String suffix)
suffix
return (suffix == null) ? name : name + suffix;
Stringsuffix(String prefix, String path)
Return path relative to prefix (its suffix, but without leading slash).
if (!path.startsWith(prefix)) {
    return null;
int end = prefix.length();
if (path.length() > end && path.charAt(end) == '/') {
    end++;
return path.substring(end);
...
Stringsuffix(String s, int delim)
Extract the portion of s after the last occurrence of the given delimiter.
int index = s.lastIndexOf(delim);
return (index == -1) ? s : s.substring(index + 1);
Stringsuffix(String s, String suffix)
suffix
if (!s.endsWith(suffix)) {
    s = s + suffix;
return s;
Stringsuffix(String str, int width, String with)
suffix
StringBuffer ret = new StringBuffer(str);
while (ret.length() < width)
    ret.append(with);
return ret.toString();