Here you can find the source of subStringWith3Point(String inputStr, int beginIndex, int length)
public static String subStringWith3Point(String inputStr, int beginIndex, int length)
//package com.java2s; public class Main { public static String subStringWith3Point(String inputStr, int beginIndex, int length) { int strLength = inputStr.length(); if (beginIndex >= strLength) { return ""; }//from w w w.ja v a2s. c o m if (beginIndex + length >= strLength) { return inputStr.substring(beginIndex); } return inputStr.substring(beginIndex, beginIndex + length - 1) + "..."; } public static String substring(String string, int beginIndex, int length) { int strLength = string.length(); if (beginIndex >= strLength) { return ""; } if (beginIndex + length >= strLength) { return string.substring(beginIndex); } return string.substring(beginIndex, beginIndex + length); } }