Java String Ends With endsWith(byte[] bytes, String str)

Here you can find the source of endsWith(byte[] bytes, String str)

Description

ends With

License

Open Source License

Declaration

static boolean endsWith(byte[] bytes, String str) 

Method Source Code

//package com.java2s;

public class Main {
    static boolean endsWith(byte[] bytes, String str) {
        if (bytes.length < str.length())
            return false;

        int actualByteCount = bytes.length;
        while ((actualByteCount > 0)
                && ((bytes[actualByteCount - 1] == '\n') || (bytes[actualByteCount - 1] == '\r')))
            actualByteCount--;/*from www .j a v a2  s .com*/
        if (actualByteCount < str.length())
            return false;

        for (int c = 0; c < str.length(); c++) {
            if (bytes[c + (actualByteCount - str.length())] != str.charAt(c))
                return false;
        }

        return true;
    }
}

Related

  1. endsWith(byte[] dataFrom, String suffix)
  2. endsWith(byte[] source, char c)
  3. endsWith(byte[] subject, byte[] suffix)
  4. endsWith(char s[], int len, char suffix[])