Java examples for java.lang:String Contain
safe Contains Ignore Case
//package com.java2s; import java.util.Locale; public class Main { public static void main(String[] argv) { String s = "java2s.com"; String lookFor = "java2s.com"; System.out.println(safeContainsIgnoreCase(s, lookFor)); }/*from w w w .java 2 s .co m*/ public static boolean safeContainsIgnoreCase(final String s, final String lookFor) { if (s == null) return lookFor == null; if (lookFor == null) return false; return s.toLowerCase(Locale.UK).contains( lookFor.toLowerCase(Locale.UK)); } }