Java String Sub String substringEL(String str, int index, String defaultValue)

Here you can find the source of substringEL(String str, int index, String defaultValue)

Description

substring EL

License

LGPL

Declaration

public static String substringEL(String str, int index, String defaultValue) 

Method Source Code

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

public class Main {
    public static String substringEL(String str, int index, String defaultValue) {
        if (str == null || index < 0 || index > str.length())
            return defaultValue;
        return str.substring(index);
    }/*w  w  w .  j a  v a 2  s  . co  m*/

    public static int length(String str) {
        if (str == null)
            return 0;
        return str.length();
    }

    /**
     * this method works different from the regular substring method, the regular substring method takes startIndex and endIndex as second and third argument,
     * this method takes offset and length
     * @param str
     * @param off
     * @param len
     * @return
     */
    public static String substring(String str, int off, int len) {
        return str.substring(off, off + len);
    }
}

Related

  1. substringByMask(String baseString, String baseMask, String subMask)
  2. subStringByte(String str, int toCount, String more)
  3. substringBytes(String value, int byte_len)
  4. substringCompare(String string, int index, char... characters)
  5. substringDelimited(String string, String start, String end, int startingPosition)
  6. substringEnd(String string, int start, int length)
  7. substringEquals(final String s1, final int fromIndex1, final int toIndex1, final String s2, final int fromIndex2, final int toIndex2)
  8. subStringExe(String s, String jmp, String sb, String se)
  9. substringFromMatch(String match, String string)