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??
From the JavaDoc of the method:
In the code of the method you find
You can read the code here: http://kickjava.com/src/org/apache/commons/lang/StringUtils.java.htm
So both examples you give should return
"abcdefg...". Are you sure you got"abcdefgh"?