Java examples for java.lang:String End
find First Ends With
//package com.java2s; import java.util.Arrays; import java.util.Collection; public class Main { public static void main(String[] argv) { String text = "java2s.com"; Collection ends = java.util.Arrays.asList("asdf", "java2s.com"); System.out.println(findFirstEndsWith(text, ends)); }//from w w w.ja va2s.com public static String findFirstEndsWith(String text, Collection<String> ends) { String res = null; for (String end : ends) { if (text.endsWith(end)) { res = end; break; } } return res; } public static String findFirstEndsWith(String text, String[] ends) { return findFirstEndsWith(text, Arrays.asList(ends)); } }