How to truncate a string in groovy?
The Groovy community has added a take() method which can be used for easy and safe string truncation. Examples: “abscd adfa dasfds ghisgirs fsdfgf”.take(10) //”abscd adfa” “It’s groovy, man”.take(4) //”It’s” “It’s groovy, man”.take(10000) //”It’s groovy, man” (no exception thrown) There’s also a corresponding drop() method: “It’s groovy, man”.drop(15) //”n” “It’s groovy, man”.drop(5).take(6) //”groovy” Both take() … Read more