Here you can find the source of endsWith(String receiver, String... needles)
public static boolean endsWith(String receiver, String... needles)
//package com.java2s; //License from project: Open Source License public class Main { public static boolean endsWith(String receiver, String... needles) { return endsWith(receiver, false, needles); }/*from w w w .j ava 2 s . co m*/ public static boolean endsWith(String receiver, boolean ignoreCase, String... needles) { if (receiver == null) return false; for (String needle : needles) { if (endsWith(receiver, ignoreCase, needle)) { return true; } } return false; } public static boolean endsWith(CharSequence receiver, String suffix, boolean ignoreCase) { return receiver.length() >= suffix.length() && regionMatches(receiver, receiver.length() - suffix.length(), suffix, 0, suffix.length(), ignoreCase); } public static boolean regionMatches(CharSequence receiver, int thisOffset, String other, int otherOffset, int length, boolean ignoreCase) { if (ignoreCase) { for (int i = 0; i < length; i++) { if (Character.toLowerCase(receiver.charAt(i + thisOffset)) != Character .toLowerCase(other.charAt(i + otherOffset))) return false; } } else { for (int i = 0; i < length; i++) { if (receiver.charAt(i + thisOffset) != other.charAt(i + otherOffset)) return false; } } return true; } }