Android String Sub String Get substringAfter(String text, char c)

Here you can find the source of substringAfter(String text, char c)

Description

Gives the substring of the given text after the given separator.

Parameter

Parameter Description
text a parameter
separator a parameter

Declaration

public static String substringAfter(String text, char c) 

Method Source Code

//package com.java2s;

public class Main {
    /**/* w  ww.  j a v a  2s  .c  o m*/
     * Gives the substring of the given text after the given separator.
     * 
     * If the text does not contain the given separator then "" is returned.
     * 
     * @param text
     * @param separator
     * @return
     */
    public static String substringAfter(String text, char c) {
        if (isEmpty(text)) {
            return text;
        }
        int cPos = text.indexOf(c);
        if (cPos < 0) {
            return "";
        }
        return text.substring(cPos + 1);
    }

    /**
     * Whether the given string is null or zero-length.
     * 
     * @param text
     * @return
     */
    public static boolean isEmpty(String text) {
        return (text == null) || (text.length() == 0);
    }
}

Related

  1. substring(String str, int len, String more)
  2. substringFromLast(final String str, final String separator)
  3. substringToLast(final String str, final String separator)
  4. takeOutFirstChar(String input)
  5. substring(String str, int srcPos, int specialCharsLength)
  6. substringAfterLast(String text, char separator)
  7. substringBefore(String text, char separator)
  8. substringBefore(String text, char separator)
  9. substringBeforeLast(String text, char separator)