Java String Sub String subStringWith3Point(String inputStr, int beginIndex, int length)

Here you can find the source of subStringWith3Point(String inputStr, int beginIndex, int length)

Description

sub String With Point

License

Open Source License

Declaration

public static String subStringWith3Point(String inputStr, int beginIndex, int length) 

Method Source Code

//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);
    }
}

Related

  1. subStringToInteger(String src, String start, String to)
  2. substringToLast(final String str, final String separator)
  3. substringUntil(String org, int begin, char term)
  4. substringUntilMatch(String string, String match)
  5. subStringWhiteSpaces(String str, int maxLen)
  6. subStrOccurences(String str, String findStr)
  7. subStrTime(String strTime)