Java String Sub String substringAfter(String text, int index)

Here you can find the source of substringAfter(String text, int index)

Description

substring After

License

Open Source License

Declaration

private static String substringAfter(String text, int index) 

Method Source Code

//package com.java2s;

public class Main {
    private static final String EMPTY = "";
    private static final int INDEX_NOT_FOUND = -1;

    public static String substringAfter(String text, String separator) {
        int index = indexOf(text, separator);
        return substringAfter(text, index);
    }//from   w  w w  .  j a v  a  2s . c om

    private static String substringAfter(String text, int index) {
        if (index == INDEX_NOT_FOUND) {
            return EMPTY;
        }
        return text.substring(index + 1, text.length());
    }

    private static int indexOf(String text, String separator) {
        if (isBlank(text)) {
            return INDEX_NOT_FOUND;
        }
        return text.indexOf(separator);
    }

    public static boolean isBlank(String text) {
        return text == null || text.trim().isEmpty();
    }
}

Related

  1. substringAfter(String str, String separator)
  2. substringAfter(String str, String separator)
  3. substringAfter(String string, String delim)
  4. substringAfter(String string, String delimiter)
  5. substringAfter(String template, String toFind, String defaultTo)
  6. substringAfter(String text, String after)
  7. substringAfter(String value, char delim)
  8. substringAfterFirstIndex(String value)
  9. substringAfterIfExist(String source, String rev)