Java String Equal areEqual(String seq1, String seq2)

Here you can find the source of areEqual(String seq1, String seq2)

Description

are Equal

License

Open Source License

Declaration

public static boolean areEqual(String seq1, String seq2) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static boolean areEqual(String seq1, String seq2) {
        return trim(seq1).equals(trim(seq2));
    }/*from w w  w  .j a  v  a 2  s  .  co m*/

    public static String trim(String toTrim) {
        if (toTrim.length() == 0)
            return toTrim;
        StringBuilder result = new StringBuilder();
        int length = toTrim.length();
        boolean space = false;
        for (int i = 0; i < length; i++) {
            char current = toTrim.charAt(i);
            if (Character.isWhitespace(current)) {
                space = result.length() > 0;
                continue;
            }
            if (Character.isJavaIdentifierPart(current))
                if (space && Character.isJavaIdentifierPart(result.charAt(result.length() - 1)))
                    result.append(' ');
            result.append(current);
            space = false;
        }
        return result.toString();
    }
}

Related

  1. areEqual(String expected, String actual)
  2. areEqual(String s1, String s2)
  3. areEqual(String s1, String s2)
  4. areEqual(String s1, String s2)
  5. areEqual(String str1, String str2)
  6. areEqual(String string1, String string2)
  7. areEqual(String string1, String string2)
  8. areEqual(String thisString, String thatString)