Here you can find the source of shorten(String s, int length)
Parameter | Description |
---|---|
s | String to shorten |
length | shortened length where elipses will start |
public static final String shorten(String s, int length)
//package com.java2s; public class Main { /**/*from w ww . j a v a 2 s . c om*/ * Shorten a string using elipses (...) * * @param s String to shorten * @param length shortened length where elipses will start * @return shortened string. */ public static final String shorten(String s, int length) { if (s.length() > length) { s = s.substring(0, length - 1) + "..."; } return s; } }