Java String Sub String substr(String str, int index)

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

Description

substr

License

Open Source License

Declaration

public static String substr(String str, int index) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static String substr(String str, int index) {
        if (str.length() < index) {
            return str;
        }/*from   w ww  .  j a va 2s  .  com*/
        str = trim(str).substring(index);
        return str;
    }

    public static String substr(String str, int beginIndex, int endIndex) {
        if (str.length() < beginIndex || str.length() < endIndex || beginIndex > endIndex) {
            return str;
        }
        return trim(str).substring(beginIndex, endIndex);
    }

    public static String trim(String str) {
        if (str == null) {
            return "";
        }
        return str.trim().replaceAll(" ", "");
    }
}

Related

  1. subStr(String src, int len)
  2. substr(String src, int nStart, int nLen)
  3. subStr(String src, String split)
  4. substr(String str, int beginIndex, int endIndex)
  5. substr(String str, int iLen)
  6. subStr(String str, int len)
  7. substr(String str, int length)
  8. subStr(String str, int limit)
  9. subStr(String str, int maxLen)