Here you can find the source of substring(String str, int beginIndex, int len)
public static String substring(String str, int beginIndex, int len)
//package com.java2s; /*/* w ww. ja va2s . co m*/ * StringHelper.java 2004-3-5 * * ??????: ???????(FTO)???? 2000-2005, ?????????. * ????????????(FTO)???????????????????????????????????????? * * Copyright 2000-2005 FTO Software Team, Inc. All Rights Reserved. * This software is the proprietary information of FTO Software Team, Inc. * Use is subject to license terms. * * FTO???http://www.free-think.org */ public class Main { public static String substring(String str, int beginIndex, int len) { int endIndex = beginIndex + len; endIndex = endIndex > str.length() ? str.length() : endIndex; return str.substring(beginIndex, endIndex); } public static String substring(String str, int beginIndex, String endStr) { int endIndex = str.indexOf(endStr, beginIndex); if (endIndex < 0) { return null; } return str.substring(beginIndex, endIndex); } public static String substring(String str, String beginStr, int len) { int beginIndex = str.indexOf(beginStr); if (beginIndex < 0) { return null; } return substring(str, beginIndex + beginStr.length(), len); } public static String substring(String str, String beginStr, String endStr) { int beginIndex = str.indexOf(beginStr); if (beginIndex < 0) { return null; } beginIndex = beginIndex + beginStr.length(); int endIndex = str.indexOf(endStr, beginIndex); if (endIndex < 0) { return null; } return str.substring(beginIndex, endIndex); } }