Java String Starts Wtih startsWith(String s, char begin)

Here you can find the source of startsWith(String s, char begin)

Description

starts With

License

Open Source License

Declaration

public static boolean startsWith(String s, char begin) 

Method Source Code

//package com.java2s;
/**// w ww.ja  v  a 2 s  . c o  m
 * Genji Scrum Tool and Issue Tracker
 * Copyright (C) 2015 Steinbeis GmbH & Co. KG Task Management Solutions
    
 * <a href="http://www.trackplus.com">Genji Scrum Tool</a>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * 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. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */

public class Main {
    public static boolean startsWith(String s, char begin) {
        return startsWith(s, Character.toString(begin));
    }

    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());

        return temp.equalsIgnoreCase(start);

    }
}

Related

  1. startsWith(String partial, String possible)
  2. startsWith(String path, String prefix)
  3. startsWith(String prefix, String string, boolean caseInsensitive)
  4. startsWith(String receiver, String... needles)
  5. startsWith(String s, boolean caseIgnore, String... args)
  6. startsWith(String s, char c)
  7. startsWith(String s, int offset, int end, String t)
  8. startsWith(String s, String begin)
  9. startswith(String s, String prefix)