clamp String to make String short - Android java.lang

Android examples for java.lang:String Format

Description

clamp String to make String short

Demo Code


//package com.java2s;

public class Main {
    public static String clampString(String str, int len) {
        if (str.length() > len)
            return str.substring(0, len - 3) + "...";
        return str;
    }/* w  w w .  ja  v  a  2 s  . c om*/
}

Related Tutorials