![]() StringUtils.abbreviate("abcdefghijklmno", 4, 10) = "abcdefg." StringUtils.abbreviate("abcdefghijklmno", 1, 10) = "abcdefg." StringUtils.abbreviate("abcdefghijklmno", 0, 10) = "abcdefg." StringUtils.abbreviate("abcdefghijklmno", -1, 10) = "abcdefg." StringUtils.abbreviate(null, *, *) = null In no case will it return a String of length greater than Note that this left edge is not necessarily going toīe the leftmost character in the result, or the first character following theĮllipses, but it will appear somewhere in the result. Works like abbreviate(String, int), but allows you to specifyĪ "left edge" offset. "Now is the time for all good men" into ".is the time for." abbreviate public static String abbreviate( String str,.Parameters: str - the String to check, may be null maxWidth - maximum length of result String, must be at least 4 Returns: abbreviated String, null if null String input Throws: IllegalArgumentException - if the width is too small Since: 2.0 StringUtils.abbreviate("abcdefg", 3) = IllegalArgumentException StringUtils.abbreviate("abcdefg", 4) = "a." StringUtils.abbreviate("abcdefg", 8) = "abcdefg" StringUtils.abbreviate("abcdefg", 7) = "abcdefg" StringUtils.abbreviate("abcdefg", 6) = "abc." In no case will it return a String of length greater than.Else abbreviate it to (substring(str, 0, max-3) + ".").If the number of characters in str is less than or equal to."Now is the time for all good men" into "Now is the time for." The symbol * is used to indicate any input including null.Ībbreviates a String using ellipses. Methods in this class include sample code in their Javadoc comments to explain their operation. NullPointerException should be considered a bug in That is to say that a null input will return null.Ī side effect of the null handling is that a StringUtils handles null input Strings quietly. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |