Java String Abbreviate abbreviate(String s, int maxLength)

Here you can find the source of abbreviate(String s, int maxLength)

Description

abbreviate

License

LGPL

Declaration

public static String abbreviate(String s, int maxLength) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

public class Main {
    public static String abbreviate(String s, int maxLength) {
        s = String.valueOf(s); // null check
        if (s.length() > maxLength) {
            s = s.substring(0, maxLength) + "...";
        }/*from   w  ww.  ja v  a2s . c o  m*/
        return s;
    }
}

Related

  1. abbreviate(String longName)
  2. abbreviate(String longStr, int maxLength)
  3. abbreviate(String name)
  4. abbreviate(String s, int length)
  5. abbreviate(String s, int max)
  6. abbreviate(String src, int maxlen, String replacement)
  7. abbreviate(String str)
  8. abbreviate(String str, int maximumChars)
  9. abbreviate(String str, int maxlen, String appendIfLimit)