public static String trimMiddle(String s, int max) {

		int len = s.length();
		if (len <= max) {
			return s;
		}

		int minimum = ELLIPSES.length() + 2; // +2 for one char on each side
		if (max < minimum) {
			throw new IllegalArgumentException("Max cannot be less than " + minimum);
		}

		int toRemove = (len - max) + ELLIPSES.length();
		int toKeep = len - toRemove;
		int lhsSize = toKeep / 2;
		int rhsSize = lhsSize;

		if (toKeep % 2 != 0) {
			rhsSize++; // compensate for roundoff on odd size
		}

		StringBuilder buffy = new StringBuilder();
		buffy.append(s.substring(0, lhsSize));
		buffy.append(ELLIPSES);
		buffy.append(s.substring(len - rhsSize, len));

		return buffy.toString();
	}
Trims the given string the <code>max</code> number of characters. Ellipses will be added to
signal that content was removed. Thus, the actual number of removed characters will be
<code>(s.length() - max) + {@value StringUtilities#ELLIPSES}</code> length.

<p>
If the string fits within the max, then the string will be returned.

<p>
The given <code>max</code> value must be at least 5. This is to ensure that, at a minimum, we
can display the {@value #ELLIPSES} plus one character from the front and back of the string.

@param s the string to trim
@param max the max number of characters to allow.
@return the trimmed string
Ghidra/Framework/Generic/src/main/java/ghidra/util/StringUtilities.java