Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

java

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']
like image 804
Mauli Avatar asked Mar 01 '23 06:03

Mauli


1 Answers

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

WordUtils.wrap

like image 67
Brandon DuRette Avatar answered Mar 15 '23 20:03

Brandon DuRette