Java Utililty Methods String Clip

List of utility methods to do String Clip

Description

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

Method

Stringclip(final String s, final int leftClip, final int rightClip)
Trims characters off the start and end of a string
return leftClip + rightClip >= s.length() ? "" : s.substring(leftClip, s.length() - rightClip);
Stringclip(String characterItem)
clip
int length = characterItem.length();
if (length > 0) {
    int startingIdx = length - 1;
    boolean charsDeleted = false;
    while (startingIdx >= 0) {
        char c = characterItem.charAt(startingIdx);
        if (c <= ' ' || c == '\u3000') {
            charsDeleted = true;
...
Stringclip(String str, int startChars)
clip
return str.length() <= startChars ? str : str.substring(0, startChars) + "...";
StringClipObjectReferenceAddress(String p_fullObjectReference)
Sometimes it is convenient for logging purposes to be able to add the reference address so that you can track the life of a particular object more easily.
return p_fullObjectReference.substring(p_fullObjectReference.indexOf('@') + 1);
StringclipString(String input, int numChars, boolean appendEllipses)
Reduces the input string to the number of chars, or its length if the number of chars exceeds the input string's length
int end = Math.min(numChars, input.length());
String output = input.substring(0, end);
if (appendEllipses) {
    output = (output.length() < input.length()) ? output + "..." : output;
return output;
StringclipText(String text, int maxLength)
clip Text
if (text.length() <= maxLength) {
    return text;
} else {
    return text.substring(0, maxLength) + "...";