code: public static boolean endsWith(
              final boolean caseSensitive,
              final CharSequence text, final int textOffset, final int textLen,
              final CharSequence suffix, final int suffixOffset, final int suffixLen) {
  
          if (text == null) {
              throw new IllegalArgumentException("Text cannot be null");
          }
          if (suffix == null) {
              throw new IllegalArgumentException("Suffix cannot be null");
          }
  
          if (textLen < suffixLen) {
              return false;
          }
  
          final int textReverseOffset = textOffset + textLen - 1;
          final int suffixReverseOffset = suffixOffset + suffixLen - 1;
  
          char c1, c2;
  
          int n = suffixLen;
          int i = 0;
  
          while (n-- != 0) {
  
              c1 = text.charAt(textReverseOffset - i);
              c2 = suffix.charAt(suffixReverseOffset - i);
  
              if (c1 != c2) {
  
                  if (caseSensitive) {
                      return false;
                  }
  
                  c1 = Character.toUpperCase(c1);
                  c2 = Character.toUpperCase(c2);
  
                  if (c1 != c2) {
  
                      // We check both upper and lower case because that is how String#equalsIgnoreCase() is defined.
                      // See String#regionMatches(boolean,int,String,int,int)
                      if (Character.toLowerCase(c1) != Character.toLowerCase(c2)) {
                          return false;
                      }
  
                  }
  
              }
  
              i++;
  
          }
  
          return true;
  
      }
docs: <p>
  Checks whether a text ends with a specified suffix, specifying (offset,len) pairs
  for limiting the fragments to be checked.
  </p>
  
  @param caseSensitive whether the comparison must be done in a case-sensitive or case-insensitive way.
  @param text the text to be checked for suffixes.
  @param textOffset the offset of the text.
  @param textLen the length of the text.
  @param suffix the suffix to be searched.
  @param suffixOffset the offset of the suffix.
  @param suffixLen the length of the suffix.
  @return whether the text ends with the suffix or not.