Here you can find the source of endsWithIgnoreCase(String s, String suffix)
Parameter | Description |
---|---|
s | the String to check, may be null |
suffix | the suffix to find, may be null |
public static boolean endsWithIgnoreCase(String s, String suffix)
//package com.java2s; // Licensed under the Apache License, Version 2.0 (the "License"); public class Main { /**//from ww w . j ava2 s. com * Check if a String ends with a specified suffix, ignoring case * * @param s the String to check, may be null * @param suffix the suffix to find, may be null * @return true if s ends with suffix or both s and suffix are null, false * otherwise. */ public static boolean endsWithIgnoreCase(String s, String suffix) { if (s == null || suffix == null) { return (s == null && suffix == null); } if (suffix.length() > s.length()) { return false; } return s.regionMatches(true, s.length() - suffix.length(), suffix, 0, suffix.length()); } }