Java String Abbreviate abbreviate(String longStr, int maxLength)

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

Description

abbreviate

License

Open Source License

Declaration

public static String abbreviate(String longStr, int maxLength) 

Method Source Code

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

public class Main {
    public static String abbreviate(String longStr, int maxLength) {
        String _longStr = getEmptyIfNull(longStr);
        return _longStr.length() > maxLength ? _longStr.substring(0, maxLength - 2) + ".." : _longStr;
    }/*from   w ww.j  a va 2s.c  o  m*/

    public static String getEmptyIfNull(String str) {
        if (str == null)
            return "";
        else
            return str;
    }
}

Related

  1. abbreviate(String _str, int _length)
  2. abbreviate(String content, int maxWidth, String enc, String suffix)
  3. abbreviate(String fileName, int maxLen)
  4. abbreviate(String input, int length)
  5. abbreviate(String longName)
  6. abbreviate(String name)
  7. abbreviate(String s, int length)
  8. abbreviate(String s, int max)
  9. abbreviate(String s, int maxLength)