Here you can find the source of endsWith(byte[] subject, byte[] suffix)
private static boolean endsWith(byte[] subject, byte[] suffix)
//package com.java2s; public class Main { /**/*from w w w. j a va 2s. co m*/ * Returns {@code true} if {@code subject} ends with {@code suffix}. */ private static boolean endsWith(byte[] subject, byte[] suffix) { int start = subject.length - suffix.length; if (start < 0) { return false; } for (int i = start; i < subject.length; i++) { if (subject[i] != suffix[i - start]) { return false; } } return true; } }