Java String Shorten shortenTo(String string, int lenght)

Here you can find the source of shortenTo(String string, int lenght)

Description

shorten To

License

Open Source License

Declaration

public static String shortenTo(String string, int lenght) 

Method Source Code

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

public class Main {
    public static String shortenTo(String string, int lenght) {
        if (string.length() > lenght) {
            string = string.substring(0, lenght - 4) + " ...";
        }//from  w  ww  .ja  v  a2  s. c  o  m
        return string;
    }
}

Related

  1. shortenText(final String text, final int maxLength, final boolean addDots)
  2. shortenText(int maxWidth, String textValue)
  3. shortenText(String originalText, int maxlength)
  4. shortenText(String string, int threshold)
  5. shortenTo(final String value, final int maxLength)
  6. shortenToFirstLast(String filename)
  7. shortenType(String typeText)
  8. shortenURI(String uri)
  9. shortenUrl(String protocolHostPart, String pathPart, String queryPart, String fragmentIdentifier)