Java String Start With startWithAorAn(String str)

Here you can find the source of startWithAorAn(String str)

Description

start With Aor An

License

Apache License

Declaration

public static String startWithAorAn(String str) 

Method Source Code

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

public class Main {
    public static String startWithAorAn(String str) {
        if (str.length() == 0)
            return str;
        if ((!str.toUpperCase().startsWith("A ")) && (!str.toUpperCase().startsWith("AN "))
                && (!str.toUpperCase().startsWith("THE ")) && (!str.toUpperCase().startsWith("SOME "))) {
            if ("aeiouAEIOU".indexOf(str.charAt(0)) >= 0)
                return "an " + str;
            return "a " + str;
        }//from  w  w  w  .  j  a v  a 2 s.  c  om
        return str;
    }
}

Related

  1. startWith(String source, String target)
  2. startWith(String str, String prefix)
  3. startWith(String str, String start)
  4. startWith(String string, String prefix)
  5. startWith(String string1, String string2)
  6. startWithBOM(byte[] array)
  7. startWithIgnoreCase(CharSequence str, CharSequence prefix)
  8. startWithIgnoreCase(String str, String prefix)
  9. startWithLowerCase(String in)