Here you can find the source of endsWithIgnoreCase(String str, String suffix)
Parameter | Description |
---|---|
str | The String to check. |
suffix | The suffix to check the String for. |
public static boolean endsWithIgnoreCase(String str, String suffix)
//package com.java2s; //License from project: Open Source License public class Main { /**/* w w w . j av a2 s. c o m*/ * Checks if the given String ends with the given suffix, ignoring case. * * @param str The String to check. * @param suffix The suffix to check the String for. * * @return True if the given String ends with the given suffix, otherwise false. */ public static boolean endsWithIgnoreCase(String str, String suffix) { if (str == null) throw new IllegalArgumentException("Parameter 'str' cannot be null!"); if (suffix == null) throw new IllegalArgumentException("Parameter 'suffix' cannot be null!"); if (str.length() < suffix.length()) return false; String ending = str.substring(str.length() - suffix.length()); return ending.equalsIgnoreCase(suffix); } }