Here you can find the source of substr(String str, int index)
public static String substr(String str, int index)
//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(" ", ""); } }