I found a class that does this, and it seems exactly what I need.
public static class StringUtil
{
public static String limit(String value, int length)
{
StringBuilder buf = new StringBuilder(value);
if (buf.length() > length)
{
buf.setLength(length);
buf.append("…");
}
return buf.toString();
}
}
I have a string called review, and I use that class this way:
StringUtil.limit(review, 50);
It does not seem to be appending.
For what it's worth, it is for an Android app. This is being done in a PostExectute method of AsyncTask inside of a ListFragement.
Am I doing this right?