Java String Sub String substringBefore(final String str, final String separator)

Here you can find the source of substringBefore(final String str, final String separator)

Description

substring Before

License

Open Source License

Declaration

public static String substringBefore(final String str,
            final String separator) 

Method Source Code

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

public class Main {
    public static String substringBefore(final String str,
            final String separator) {
        if (str == null || str.length() == 0) {
            return str;
        }/*from w ww  .  ja  va 2s .c  o  m*/
        if (separator == null || str.indexOf(separator) == -1) {
            return str;
        }
        return str.substring(0, str.indexOf(separator));
    }
}

Related

  1. subStringAfterLastSymbol(String inStr, char symbol)
  2. substringAfterReturnAll(String str, String before)
  3. substringAndchopLastNewline(String text, int start_pos, int end_pos)
  4. subStringArray(String in[], int start, int end)
  5. substringBaseName(String baseName, int extraCharsNumber)
  6. substringBefore(final String string, final String separator)
  7. substringBefore(String input, String sub)
  8. substringBefore(String s, char c)
  9. substringBefore(String str, int endChar)