Here you can find the source of startswith(String s, String prefix)
Parameter | Description |
---|---|
s | The string to examine |
prefix | The prefix to try |
public static boolean startswith(String s, String prefix)
//package com.java2s; /**// ww w . j a v a 2s . co m * Copyright (C) 2011 Darien Hager * * This code is part of the "HL2Parse" project, and is licensed under * a Creative Commons Attribution-ShareAlike 3.0 Unported License. For * either a summary of conditions or the full legal text, please visit: * * http://creativecommons.org/licenses/by-sa/3.0/ * * Permissions beyond the scope of this license may be available * at http://technofovea.com/ . */ public class Main { /** * This function performs a case-insensitive starts-with test. * @param s The string to examine * @param prefix The prefix to try * @return True if the first string starts with the second, ignoring case. */ public static boolean startswith(String s, String prefix) { if (s == null || prefix == null) { return false; } return s.toLowerCase().startsWith(prefix.toLowerCase()); } }