Android examples for java.lang:String Strip
trim Char Sequence from Spanned
import android.text.SpannableStringBuilder; import android.text.Spanned; public class Main{ public static String trimCharSequence(final String text, final int size) { return text.length() > size ? text.substring(0, size) : text; }/*from w w w. j a va 2s .c o m*/ public static Spanned trimCharSequence(final Spanned spanned, final int size) { return spanned.length() > size ? new SpannableStringBuilder( spanned, 0, size) : spanned; } }