Java String Starts Wtih startsWith(String s, String prefix)

Here you can find the source of startsWith(String s, String prefix)

Description

starts With

License

Apache License

Declaration

public static boolean startsWith(String s, String prefix) 

Method Source Code

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

public class Main {
    public static boolean startsWith(String s, String prefix) {
        if (s == null) {
            return false;
        }//from w  ww. j  a  v  a2  s.  c o  m

        for (int i = 0; i < s.length(); i++) {
            if (Character.isWhitespace(s.charAt(i))) {
                continue;
            } else {
                return s.regionMatches(i, prefix, 0, prefix.length());
            }
        }

        return false;
    }
}

Related

  1. startsWith(String s, char begin)
  2. startsWith(String s, char c)
  3. startsWith(String s, int offset, int end, String t)
  4. startsWith(String s, String begin)
  5. startswith(String s, String prefix)
  6. startsWith(String s, String prefix)
  7. startsWith(String s, String start)
  8. startsWith(String s, String start)
  9. startsWith(String s1, String s2)