Here you can find the source of substr(String str, int iLen)
Parameter | Description |
---|---|
str | in string |
iLen | specify length |
public static String substr(String str, int iLen)
//package com.java2s; //License from project: Apache License public class Main { /**/* ww w . j a v a 2 s .c o m*/ * we'll cut it if the length of the specify string longer than specify length * * @param str in string * @param iLen specify length * @return out string */ public static String substr(String str, int iLen) { if (str == null) return ""; if (iLen > 2) { if (str.length() > iLen - 2) { str = str.substring(0, iLen - 2) + ".."; } } return str; } }