@@ -0,0 +1,1337 @@
+package com.vsked.test;%0D%0A%0D%0Aimport java.util.regex.Matcher;%0D%0Aimport java.util.regex.Pattern;%0D%0A%0D%0Apublic class EndWithTest %7B%0D%0A%0D%0A%09public static void main(String%5B%5D args) %7B%0D%0A//%09%09test1a();%0D%0A%09%09test1();%0D%0A%09%09test2();%0D%0A%09%7D%0D%0A%09%0D%0A%09public static void test1a()%7B%0D%0A%09%09String s=%22abcc123%22;%0D%0A%09%09boolean f=s.endsWith(%22123f%22);%0D%0A%09%09System.out.println(f);%0D%0A%09%7D%0D%0A%09%0D%0A%09public static void test1() %7B%0D%0A%09%09Pattern pattern = Pattern.compile(%22%5C%5C.(jpg%7Cpng%7Cgif)$%22, Pattern.CASE_INSENSITIVE);%0D%0A%09%09String fileName = %22agifpngjpgb.GIF%22;%0D%0A%0D%0A%09%09long begin = System.currentTimeMillis();%0D%0A%09%09for (int i = 1000000; i %3E 0; i--) %7B%0D%0A%09%09%09Matcher matcher = pattern.matcher(fileName);%0D%0A%09%09%09matcher.find();%0D%0A%09%09%7D%0D%0A%09%09long end = System.currentTimeMillis();%0D%0A%09%09System.out.println(%22regexp: %22 + (end - begin));%0D%0A%09%7D%0D%0A%0D%0A%09public static void test2() %7B%0D%0A%09%09String%5B%5D suffixs = %7B %22jpg%22, %22png%22, %22gif%22 %7D;%0D%0A%09%09String fileName = %22agifpngjpgb.GIF%22;%0D%0A%09%09String temp = null;%0D%0A%0D%0A%09%09long begin = System.currentTimeMillis();%0D%0A%09%09for (int i = 1000000; i %3E 0; i--) %7B%0D%0A%09%09%09temp = fileName.toLowerCase();%0D%0A%09%09%09check1(suffixs, temp);%0D%0A%09%09%7D%0D%0A%09%09long end = System.currentTimeMillis();%0D%0A%09%09System.out.println(%22endwith: %22 + (end - begin));%0D%0A%09%7D%0D%0A%0D%0A%09private static boolean check1(String%5B%5D suffixs, String fileName) %7B%0D%0A%09%09for (String suffix : suffixs) %7B%0D%0A%09%09%09if (fileName.endsWith(suffix)) %7B%0D%0A%09%09%09%09return true;%0D%0A%09%09%09%7D%0D%0A%09%09%7D%0D%0A%09%09return false;%0D%0A%09%7D%0D%0A%0D%0A%7D%0D%0A

add test endwith and regulardemo