String (final String str) { int right = str.length() - 1; while (right > 0 && Verifier.isXMLWhitespace(str.charAt(right))) { right--; } int left = 0; while (left <= right && Verifier.isXMLWhitespace(str.charAt(left))) { left++; } if (left > right) { return ""; } return str.substring(left, right + 1); }