Here you can find the source of substringWithoutException(String text, int startIndex, int endIndex)
public static String substringWithoutException(String text, int startIndex, int endIndex)
//package com.java2s; //License from project: Open Source License public class Main { public static String substringWithoutException(String text, int startIndex, int endIndex) { if (isNullOrEmpty(text) || startIndex >= text.length()) { return ""; }/* www . ja v a2 s. c o m*/ final StringBuilder stringBuilder = new StringBuilder(); final int realEndIndex = endIndex >= text.length() ? text.length() - 1 : endIndex; for (int i = startIndex; i <= realEndIndex; i++) { stringBuilder.append(text.charAt(i)); } return stringBuilder.toString(); } public static boolean isNullOrEmpty(String string) { return string == null || string.isEmpty(); } }