Here you can find the source of endsWith(String s, String end)
true
if the string ends with the string end
.
Parameter | Description |
---|---|
s | the string in which to search |
end | the string to check for at the end of the string |
true
if the string ends with the string end
; false
otherwise
public static boolean endsWith(String s, String end)
//package com.java2s; //License from project: Open Source License public class Main { /**// w ww . j a v a 2s . c o m * Returns <code>true</code> if the string ends with the specified character. * * @param s the string in which to search * @param end the character to search for at the end of the string * @return <code>true</code> if the string ends with the specified character; <code>false</code> otherwise */ public static boolean endsWith(String s, char end) { return endsWith(s, (new Character(end)).toString()); } /** * Returns <code>true</code> if the string ends with the string <code>end</code>. * * @param s the string in which to search * @param end the string to check for at the end of the string * @return <code>true</code> if the string ends with the string <code>end</code>; <code>false</code> otherwise */ public static boolean endsWith(String s, String end) { if ((s == null) || (end == null)) { return false; } if (end.length() > s.length()) { return false; } String temp = s.substring(s.length() - end.length()); if (temp.equalsIgnoreCase(end)) { return true; } else { return false; } } }