Java String Equal areEqualsIgnoreCaseAndTrim(final String s1, final String s2)

Here you can find the source of areEqualsIgnoreCaseAndTrim(final String s1, final String s2)

Description

Compare two String to see if they are equals ignoring the case and the blank spaces (both null is ok).

License

Apache License

Parameter

Parameter Description
s1 string
s2 string

Return

if two String are equals ignoring the case and the blank spaces

Declaration

public static boolean areEqualsIgnoreCaseAndTrim(final String s1, final String s2) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    /**//w w w . ja  va 2  s.  com
     * Compare two String to see if they are equals ignoring the case and the blank spaces (both null is ok).
     *
     * @param s1 string
     * @param s2 string
     * @return if two String are equals ignoring the case and the blank spaces
     */
    public static boolean areEqualsIgnoreCaseAndTrim(final String s1, final String s2) {
        if (s1 == null && s2 == null) {
            return true;
        } else if (s1 != null && s2 != null) {
            return s1.trim().equalsIgnoreCase(s2.trim());
        } else {
            return false;
        }
    }
}

Related

  1. areEqualIgnoreCase(String s1, String s2)
  2. areEqualIgnoreNull(String value1, String value2, boolean caseSensitive)
  3. areEqualLexemes(String l1, String l2)
  4. areEquals(final String origin, final String checkWith)
  5. areEquals(final String s1, final String s2)
  6. areEqualXMLValues(String s1, String s2)
  7. areStringEquals(String s1, String s2)
  8. areStringEquals(String string1, String string2)
  9. areStringsEqual(String one, String two)