Java String Truncate truncateIfTooLong(String string, int maxLength)

Here you can find the source of truncateIfTooLong(String string, int maxLength)

Description

truncate If Too Long

License

Open Source License

Declaration

public static String truncateIfTooLong(String string, int maxLength) 

Method Source Code

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

public class Main {
    public static String truncateIfTooLong(String string, int maxLength) {
        if (string.length() > maxLength) {
            return string.substring(0, maxLength) + "...";
        } else {//  www  .ja  v a 2 s .c  om
            return string;
        }
    }
}

Related

  1. truncateExtension(String name)
  2. truncateFileName(String agent, String s)
  3. truncateFileType(String p)
  4. truncateFirstEnd(String str)
  5. truncateHashToInt(String hash)
  6. truncateIgnoreCase(String aString, String trailingSubString)
  7. truncateInt(String intStr)
  8. truncateJavaBeanMethodName(String methodName, int prefixLength)
  9. truncateLabel(String label)