Here you can find the source of endsWith(byte[] bytes, String str)
static boolean endsWith(byte[] bytes, String str)
//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; } }