Here you can find the source of endsWithIgnoreCase(final String haystack, final String needle)
public static boolean endsWithIgnoreCase(final String haystack, final String needle)
//package com.java2s; public class Main { public static boolean endsWithIgnoreCase(final String haystack, final String needle) { if (haystack == null) throw new IllegalArgumentException("Parameter 'haystack' is null."); if (needle == null) throw new IllegalArgumentException("Parameter 'needle' is null."); final int nl = needle.length(); final int hl = haystack.length(); if (nl == hl) { return haystack.equalsIgnoreCase(needle); }//from w w w.j av a2s . c om if (nl > hl) { return false; } // Inspired by https://stackoverflow.com/a/19154150/ final int toffset = hl - nl; return haystack.regionMatches(true, toffset, needle, 0, nl); } }