Java String Start With startWith(String string1, String string2)

Here you can find the source of startWith(String string1, String string2)

Description

Indicates if the string 1 starts with string2.

License

Open Source License

Parameter

Parameter Description
string1 String to test
string2 String to be contained

Return

true, If the string1 starts with string2

Declaration

public static Boolean startWith(String string1, String string2) 

Method Source Code

//package com.java2s;
/*//from  ww w .  ja  va 2 s . c om
 * Copyright ? WebServices pour l'?ducation, 2014
 *
 * This file is part of ENT Core. ENT Core is a versatile ENT engine based on the JVM.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation (version 3 of the License).
 *
 * For the sake of explanation, any module that communicate over native
 * Web protocols, such as HTTP, with ENT Core is outside the scope of this
 * license and could be license under its own terms. This is merely considered
 * normal use of ENT Core, and does not fall under the heading of "covered work".
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 */

public class Main {
    /**
     * Indicates if the string 1 starts with string2.
     * 
     * @param string1 String to test
     * @param string2 String to be contained
     * 
     * @return true, If the string1 starts with string2
     */
    public static Boolean startWith(String string1, String string2) {
        return (string1 != null) ? string1.startsWith(string2) : false;
    }
}

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. startWithAorAn(String str)
  6. startWithBOM(byte[] array)
  7. startWithIgnoreCase(CharSequence str, CharSequence prefix)
  8. startWithIgnoreCase(String str, String prefix)