Here you can find the source of endsWith(CharSequence cs, String postfix)
cs
ends with postfix
.
Parameter | Description |
---|---|
cs | the string sequence to check for <code>postfix</code> |
postfix | the postfix to test for |
true
if sb
ends with postfix
, false
else
public static boolean endsWith(CharSequence cs, String postfix)
//package com.java2s; //License from project: Apache License public class Main { /**/*from w w w.j av a 2 s.co m*/ * Returns whether <code>cs</code> ends with <code>postfix</code>. * * @param cs the string sequence to check for <code>postfix</code> * @param postfix the postfix to test for * @return <code>true</code> if <code>sb</code> ends with * <code>postfix</code>, <code>false</code> else * * @since 1.00 */ public static boolean endsWith(CharSequence cs, String postfix) { boolean match; int sbLen = cs.length(); int pLen = postfix.length(); if (sbLen >= pLen) { match = true; for (int p = pLen - 1, s = sbLen - 1; match && p >= 0; p--, s--) { match = postfix.charAt(p) == cs.charAt(s); } } else { match = false; } return match; } }