Java String Shorten shortenString(String string, int minimumLength, int lengthToShortenBy)

Here you can find the source of shortenString(String string, int minimumLength, int lengthToShortenBy)

Description

shorten String

License

Open Source License

Declaration

public static String shortenString(String string, int minimumLength, int lengthToShortenBy) 

Method Source Code

//package com.java2s;

public class Main {
    public static String shortenString(String string, int minimumLength, int lengthToShortenBy) {
        int minIndex = Math.min(string.length(), minimumLength);
        int maxIndex = string.length() - lengthToShortenBy;
        return string.substring(0, Math.max(minIndex, maxIndex));
    }//from   w  w w.j  a v a  2  s . co  m
}

Related

  1. shortenString(String orig, int maxLength)
  2. shortenString(String s, int maxLength)
  3. shortenString(String s, int requiredLength)
  4. shortenString(String source, int minLength, int maxLength, String suffix)
  5. shortenString(String str, int i)
  6. shortenString(String string, int targetLength, int maxDeviation)
  7. shortenStringForDisplay(String str, int desiredLen)
  8. shortenStringIfNecessary(String string, int maxLength, String suffixToAppend)
  9. shortenStringsByRemovingVowelsToFit(String s1, String s2, int maximumStringLength)