Java String Sub String subStr(String src, String split)

Here you can find the source of subStr(String src, String split)

Description

sub Str

License

Open Source License

Declaration

public static String subStr(String src, String split) 

Method Source Code

//package com.java2s;

public class Main {

    public static String subStr(String src, String split) {
        if (!(isEmpty(src))) {
            int index = src.indexOf(split);
            if (index >= 0)
                return src.substring(0, index);
        }// w w  w.java 2 s. c  o  m

        return src;
    }

    public static boolean isEmpty(String s) {
        return ((s == null) || ("".equals(s)));
    }

    public static String isEmpty(String s, String result) {
        if ((s != null) && (!(s.equals(""))))
            return s;

        return result;
    }

    public static boolean equals(String s1, String s2) {
        if ((isEmpty(s1)) && (isEmpty(s2)))
            return true;
        if ((!(isEmpty(s1))) && (!(isEmpty(s2))))
            return s1.equals(s2);

        return false;
    }
}

Related

  1. substr(String s, int start, int end)
  2. substr(String s, String sub, boolean before)
  3. substr(String src, int beginIndex, int endIndex)
  4. subStr(String src, int len)
  5. substr(String src, int nStart, int nLen)
  6. substr(String str, int beginIndex, int endIndex)
  7. substr(String str, int iLen)
  8. substr(String str, int index)
  9. subStr(String str, int len)