Java String Sub String substringBefore(String s, char c)

Here you can find the source of substringBefore(String s, char c)

Description

substring Before

License

Open Source License

Declaration

public static String substringBefore(String s, char c) 

Method Source Code

//package com.java2s;
/*/* w w  w  .  ja v  a  2 s.  c  om*/
 *        _____                     __    _     _   _____ _
 *       |   __|___ ___ _ _ ___ ___|  |  |_|___| |_|  _  | |_ _ ___
 *       |__   | -_|  _| | | -_|  _|  |__| |_ -|  _|   __| | | |_ -|
 *       |_____|___|_|  \_/|___|_| |_____|_|___|_| |__|  |_|___|___|
 *
 *  ServerListPlus - http://git.io/slp
 *  Copyright (c) 2014, Minecrell <https://github.com/Minecrell>
 *
 *     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 String substringBefore(String s, char c) {
        int pos = s.indexOf(c);
        return pos >= 0 ? s.substring(0, pos) : s;
    }
}

Related

  1. subStringArray(String in[], int start, int end)
  2. substringBaseName(String baseName, int extraCharsNumber)
  3. substringBefore(final String str, final String separator)
  4. substringBefore(final String string, final String separator)
  5. substringBefore(String input, String sub)
  6. substringBefore(String str, int endChar)
  7. substringBefore(String str, String separator)
  8. substringBefore(String str, String separator)
  9. substringBefore(String str, String separator)