Category Archives: apache-stringutils

How does the offset parameter works in the function abbreviate(String str,int offset,int maxWidth), in package org.apache.commons.lang.StringUtils

I am presently working with the apache commons lang package, StringUtils class. I found there are two abbreviation methods: abbreviate(String str,int maxwidth) and abbreviate(String str,int offset,int maxwidth) it is absolutely ok with the first one. But when come to the second one it is little bit confusing and I really need the clarification. I saw two cases of the abbreviate(String str,int offset,int maxwidth) function. those are:-

abbreviate("abcdefghijklmno",1,10)

returns "abcdefg...", and the second:

abbreviate("abcdefghijklmno",4,10)

also returns "abcdefg...".

After seeing this I am really in confution how exactly the offset parameter works??