Here you can find the source of startsWith(String prefix, String string, boolean caseInsensitive)
public static boolean startsWith(String prefix, String string, boolean caseInsensitive)
//package com.java2s; // Licensed under the Apache License, Version 2.0 (the "License"); public class Main { /**// w w w. jav a 2 s . c om * Check that string starts with specified prefix. * <p/> * <p>If {@code caseInsensitive == false} this check is equivalent * to {@link String#startsWith(String)}. * <p/> * <p>Otherwise {@code prefix} should be lower-case and check ignores * case of {@code string}. */ public static boolean startsWith(String prefix, String string, boolean caseInsensitive) { if (caseInsensitive) { int prefixLength = prefix.length(); if (string.length() < prefixLength) { return false; } return prefix.equals(string.substring(0, prefixLength).toLowerCase()); } else { return string.startsWith(prefix); } } }