Android String Shorten shortenString(String str, int length)

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

Description

shorten String

Declaration

public static String shortenString(String str, int length) 

Method Source Code

//package com.java2s;

public class Main {
    public static String shortenString(String str, int length) {
        if (str.length() > length) {
            String newStr = str.substring(0, length);
            return newStr.concat("...");
        }/*from  w  ww.  j  a va  2s. c o m*/
        return str;
    }
}

Related

  1. truncate(String text, int length)
  2. truncateAt(String string, int length)
  3. curtail(String str, int size, String tail)
  4. truncateString(String resource, String startTag, String endTag)
  5. truncateAtMaxLength(String source, int maxLength, boolean addEllipsis)
  6. ellipsizeString(String string, int limit)
  7. ellipsize(final String text, final int length)