Java String Sub String substringAfter(String sourceStr, String expr)

Here you can find the source of substringAfter(String sourceStr, String expr)

Description

substring After

License

Apache License

Declaration

public static String substringAfter(String sourceStr, String expr) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {

    public static String substringAfter(String sourceStr, String expr) {
        if (isEmpty(sourceStr) || expr == null) {
            return sourceStr;
        }//from   w  w w. j a  v a 2 s .  c o m
        if (expr.length() == 0) {
            return sourceStr;
        }

        int pos = sourceStr.indexOf(expr);
        if (pos == -1) {
            return sourceStr;
        }
        return sourceStr.substring(pos + expr.length());
    }

    public static boolean isEmpty(String chkStr) {
        if (chkStr == null) {
            return true;
        } else {
            return "".equals(chkStr.trim()) ? true : false;
        }
    }

    public static boolean isEmpty(CharSequence chkSeq) {
        if (chkSeq == null) {
            return true;
        } else {
            return "".equals(chkSeq.toString().trim()) ? true : false;
        }
    }

    public static String toString(Object obj) {
        return obj == null ? "" : obj.toString();
    }

    public static String toString(Object obj, String nullStr) {
        return obj == null ? nullStr : obj.toString();
    }
}

Related

  1. substring2ByteString(String str, int endIndex)
  2. subString4lastIndex(String string, String regex)
  3. substringAfter(final String str, final String separator)
  4. substringAfter(String s, String cs)
  5. substringAfter(String s, String substr, boolean fromend)
  6. substringAfter(String str, int beginChar, boolean last)
  7. substringAfter(String str, String delimiter)
  8. substringAfter(String str, String separator)
  9. substringAfter(String str, String separator)