get Shorted string Content - Android java.lang

Android examples for java.lang:String Shorten

Description

get Shorted string Content

Demo Code

import android.text.TextUtils;
import java.util.regex.Pattern;

public class Main{

    public static String getShortedContent(String str) {

        if (str == null) {
            return "";
        } else if (str.length() > 12) {
            String shorted = str.substring(0, 11) + "....";
            return shorted;
        } else {//w w  w . j a  va  2  s  .com
            return str;
        }
    }

}

Related Tutorials