Java String Shorten shorten(String str, int length)

Here you can find the source of shorten(String str, int length)

Description

shorten

License

Open Source License

Declaration

public static String shorten(String str, int length) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static String shorten(String str, int length) {
        if (str.length() <= length)
            return str;

        return str.substring(0, length - 3) + "...";
    }/*from   w  w  w. j  a  va2s .  c o m*/
}

Related

  1. shorten(String s, int length, String suffix)
  2. shorten(String s, int length, String suffix)
  3. shorten(String s, int max)
  4. shorten(String s, int maxLength)
  5. shorten(String script, int length)
  6. shorten(String str, int length)
  7. shorten(String string, boolean isPrefix)
  8. shorten(String string, int size)
  9. shorten(String string, int upTo)