Here you can find the source of endsWith(String str, String end, boolean caseSensitive)
public static boolean endsWith(String str, String end, boolean caseSensitive)
//package com.java2s; //License from project: Open Source License public class Main { public static boolean endsWith(String str, String end, boolean caseSensitive) { if (str == null || end == null) { return (str == null && end == null); }//from w ww . j av a 2 s . com if (end.length() > str.length()) { return false; } int offset = str.length() - end.length(); return str.regionMatches(caseSensitive, offset, end, 0, end.length()); } }