Can I wrap text to a given width with Guava?

I would like to be able to wrap a long String to a fixed length. Is there a way to do that in Guava?

Apache Commons / Lang has the method WordUtils.wrap(String, length) that does exactly what I need. Does Guava have a simple means to accomplish this?

I know I can do a hard wrap using Splitter.fixedLength(int), but I would like a soft wrap.


UPDATE: There is now a bounty for this question.

Obviously this functionality isn't available in Guava out of the Box, so the bounty goes to the most concise (or most complete) and Guava-like answer that uses what's there in Guava. No libs except Guava allowed.

23
задан Sean Patrick Floyd 16 April 2011 в 13:42
поделиться