prune method
Returns a string of reduced size. Length of returned string is
<=pruneLength
Ensured that the words will not be broken, returned string is always less
than or equal to the pruneLength
provided
Implementation
String prune(int pruneLength) {
String result;
if (this.length <= pruneLength)
result = this;
else {
result = this.substring(0, pruneLength);
if (this[pruneLength] != " ") {
result = result.substring(0, result.lastIndexOf(" "));
}
}
return result;
}