boolean (@NotNull CharSequence s1, @NotNull CharSequence s2) { int start1 = 0; int end1 = s1.length(); int end2 = s2.length(); while (start1 < end1) { char c = s1.charAt(start1); if (!isWhiteSpace(c)) break; start1++; } while (start1 < end1) { char c = s1.charAt(end1 - 1); if (!isWhiteSpace(c)) break; end1--; } int start2 = 0; while (start2 < end2) { char c = s2.charAt(start2); if (!isWhiteSpace(c)) break; start2++; } while (start2 < end2) { char c = s2.charAt(end2 - 1); if (!isWhiteSpace(c)) break; end2--; } CharSequence ts1 = new CharSequenceSubSequence(s1, start1, end1); CharSequence ts2 = new CharSequenceSubSequence(s2, start2, end2); return StringUtilRt.equal(ts1, ts2, true); }