Mauli
Mauli

Reputation: 17203

Is there a text wrap function in the java standard library?

The Python standard lib comes with the module textwrap which provides a simple text wrapping functionality. Is there something comparable in the java standard library?

in Python it is something like this:

>>> t = "a really really long string with lots of characters"
>>> import textwrap
>>> textwrap.wrap(t, 20)
['a really really long', 'string with lots of', 'characters']

Upvotes: 4

Views: 2655

Answers (1)

Brandon DuRette
Brandon DuRette

Reputation: 4870

There is not in the standard Java library, but there is in Apache Commons:

WordUtils.wrap

Upvotes: 8

Related Questions