xxxxxxxxxx
// truncates str to certain length with "..." at the end
public static String truncate(String str, int length) {
assert length >= 3 : length;
length = length - 3;
if (str.length() <= length)
return str;
else
return str.substring(0, length) + "...";
}