Here you can find the source of endsWith(final String src, final String... suffixes)
Parameter | Description |
---|---|
src | the source string to be tested |
suffixes | the set of suffixes |
public static boolean endsWith(final String src, final String... suffixes)
//package com.java2s; //License from project: Open Source License public class Main { /**/*from w w w. ja va 2 s. co m*/ * Test to see if a given string ends with some suffixes. Avoids the cost * of concatenating the suffixes together * * @param src the source string to be tested * @param suffixes the set of suffixes * @return true if src ends with the suffixes concatenated together */ public static boolean endsWith(final String src, final String... suffixes) { int pos = src.length(); for (int i = suffixes.length - 1; i >= 0; i--) { final String suffix = suffixes[i]; pos -= suffix.length(); if (!src.startsWith(suffix, pos)) { return false; } } return true; } }