Here you can find the source of contains(String[] str, String searchStr)
public static boolean contains(String[] str, String searchStr)
/**/*from w ww.ja va 2 s .c o m*/ * Copyright 2013 ?????? * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import java.net.MalformedURLException; import java.net.URL; import java.text.DecimalFormat; import java.util.ArrayList; import java.util.List; import java.util.Set; import java.util.StringTokenizer; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main{ public static final int INDEX_NOT_FOUND = -1; public static boolean contains(String str, String searchStr) { if (str == null || searchStr == null) { return false; } return str.indexOf(searchStr) > INDEX_NOT_FOUND; } public static boolean contains(String[] str, String searchStr) { boolean val = false; if (str == null || searchStr == null) { return val; } for (String s : str) { if (StringUtil.equals(s, searchStr)) { val = true; break; } } return val; } public static boolean contains(String str, List<String> keywords) { if (str == null || keywords == null) { return false; } for (String key : keywords) { if (contains(str, key)) { return true; } } return false; } public static boolean equals(String str1, String str2) { return str1 == null ? str2 == null : str1.equals(str2); } }