Java String Truncate truncVal(String s)

Here you can find the source of truncVal(String s)

Description

trunc Val

License

Apache License

Declaration

public static String truncVal(String s) 

Method Source Code

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

public class Main {
    public static String truncVal(String s) {
        if (s == null) {
            return "";
        }//  www .  j  av a  2  s .  co m

        int len = Math.min(s.length(), 10);
        String postfix = "";
        if (s.length() > len) {
            postfix = "...";
        }

        return s.substring(0, len) + postfix;
    }
}

Related

  1. truncateWithDefault(String value, int size, String defaultValue)
  2. truncateWithEllipsis(String str, int maxLength)
  3. truncAtWord(String a_text, int a_length)
  4. truncString(String in, int len)
  5. truncuate(String s, int maximumLength, String append)