Here you can find the source of endsWith(String s, String suffix)
public static boolean endsWith(String s, String suffix)
//package com.java2s; //License from project: Apache License public class Main { public static boolean endsWith(String s, String suffix) { if (s == null) { return false; }// w w w .j a v a 2s .c om for (int i = s.length() - 1; i >= 0; i--) { if (Character.isWhitespace(s.charAt(i))) { continue; } else { return s.regionMatches(i - suffix.length() + 1, suffix, 0, suffix.length()); } } return false; } }