Here you can find the source of endsWith(char s[], int len, char suffix[])
Parameter | Description |
---|---|
s | Input Buffer |
len | length of input buffer |
suffix | Suffix string to test |
s
ends with suffix
public static boolean endsWith(char s[], int len, char suffix[])
//package com.java2s; /*//from ww w . j a v a 2 s .c o m * Carrot2 project. * * Copyright (C) 2002-2016, Dawid Weiss, Stanis?aw Osi?ski. * All rights reserved. * * Refer to the full license file "carrot2.LICENSE" * in the root folder of the repository checkout or at: * http://www.carrot2.org/carrot2.LICENSE */ public class Main { /** * Returns true if the character array ends with the suffix. * * @param s Input Buffer * @param len length of input buffer * @param suffix Suffix string to test * @return true if <code>s</code> ends with <code>suffix</code> */ public static boolean endsWith(char s[], int len, String suffix) { final int suffixLen = suffix.length(); if (suffixLen > len) return false; for (int i = suffixLen - 1; i >= 0; i--) if (s[len - (suffixLen - i)] != suffix.charAt(i)) return false; return true; } /** * Returns true if the character array ends with the suffix. * * @param s Input Buffer * @param len length of input buffer * @param suffix Suffix string to test * @return true if <code>s</code> ends with <code>suffix</code> */ public static boolean endsWith(char s[], int len, char suffix[]) { final int suffixLen = suffix.length; if (suffixLen > len) return false; for (int i = suffixLen - 1; i >= 0; i--) if (s[len - (suffixLen - i)] != suffix[i]) return false; return true; } }