Java String Starts Wtih startsWithConcatenationOf(String testee, String firstPrefix, String secondPrefix)

Here you can find the source of startsWithConcatenationOf(String testee, String firstPrefix, String secondPrefix)

Description

Equivalent to testee.startsWith(firstPrefix + secondPrefix) but avoids creating an object for concatenation.

License

Open Source License

Parameter

Parameter Description
testee a parameter
firstPrefix a parameter
secondPrefix a parameter

Declaration

public static boolean startsWithConcatenationOf(String testee, String firstPrefix, String secondPrefix) 

Method Source Code

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

public class Main {
    /**//  w  w  w.  j a  v  a 2 s. c  o m
     * Equivalent to testee.startsWith(firstPrefix + secondPrefix) but avoids
     * creating an object for concatenation.
     * 
     * @param testee
     * @param firstPrefix
     * @param secondPrefix
     * @return
     */
    public static boolean startsWithConcatenationOf(String testee, String firstPrefix, String secondPrefix) {
        int l1 = firstPrefix.length();
        int l2 = secondPrefix.length();
        if (testee.length() < l1 + l2)
            return false;
        return testee.startsWith(firstPrefix) && testee.regionMatches(l1, secondPrefix, 0, l2);
    }
}

Related

  1. startsWithChar(String string, int character)
  2. startsWithCharacter(String str, char stringStart)
  3. startsWithCharacter(String str, String matchChars)
  4. startsWithCommonPackagePrefix(String inputText)
  5. startsWithConcatenation(String string, String... prefixes)
  6. startsWithCS(String a, String b)
  7. startsWithDigitsFollowedByLetters(String str)
  8. startsWithHtml(Object object)
  9. startsWithIC(String s1, String... strings)