Java String Abbreviate abbreviation(String description)

Here you can find the source of abbreviation(String description)

Description

Given a string description, returns description if its length is no greater than 10, or description + "..."

License

Open Source License

Declaration

public static String abbreviation(String description) 

Method Source Code

//package com.java2s;

public class Main {
    /**//from   w w  w . j  a v  a2s.c  o  m
     * Given a string <code>description</code>, returns <code>description</code>
     * if its length is no greater than 10, or <code>description</code> + "..."
     * otherwise.
     */
    public static String abbreviation(String description) {
        return "\"" + description.substring(0, Math.min(10, description.length()))
                + (description.length() > 10 ? "(...)" : "") + "\"";
    }
}

Related

  1. abbreviateMiddle(String string, int maxLength)
  2. abbreviateObj(Object value, int maxWidth)
  3. abbreviateScript(String script)
  4. abbreviateText(final String text, final int numberOfCharacters, final String appendText)
  5. abbreviateText(String text, int maxLength)
  6. abbreviationtoLetter(String mutation)
  7. abbrv(String str, int max)