Here you can find the source of startsWith(String s, String start)
true
if, ignoring case, the string starts with the specified start string.
Parameter | Description |
---|---|
s | the original string |
start | the string against which the beginning of string <code>s</code> are to be compared |
true
if, ignoring case, the string starts with the specified start string; false
otherwise
public static boolean startsWith(String s, String start)
//package com.java2s; //License from project: Open Source License public class Main { /**//ww w.j a v a 2 s.co m * Returns <code>true</code> if, ignoring case, the string starts with the specified character. * * @param s the string * @param begin the character against which the initial character of the string is to be compared * @return <code>true</code> if, ignoring case, the string starts with the specified character; <code>false</code> otherwise */ public static boolean startsWith(String s, char begin) { return startsWith(s, (new Character(begin)).toString()); } /** * Returns <code>true</code> if, ignoring case, the string starts with the specified start string. * * @param s the original string * @param start the string against which the beginning of string <code>s</code> are to be compared * @return <code>true</code> if, ignoring case, the string starts with the specified start string; <code>false</code> otherwise */ public static boolean startsWith(String s, String start) { if ((s == null) || (start == null)) { return false; } if (start.length() > s.length()) { return false; } String temp = s.substring(0, start.length()); if (temp.equalsIgnoreCase(start)) { return true; } else { return false; } } }