Truncate String in Groovy
// this adds a "truncate(#)" method to String String.metaClass.truncate = { len -> if (delegate == null) {return''} if (delegate.length() > len) {return delegate[0..(len - 2)] + "\u2026"} return delegate }