Nimit
Nimit

Reputation: 135

How to get substring without cutting words in between in Java?

I have so many strings and i want to print them all one by one. problem is, i have limited width to print the string. so is there any way to know when the width ends and remaining string should come in next line. and words should not be cut.

Thanks in advance...

Upvotes: 1

Views: 927

Answers (2)

Ted Hopp
Ted Hopp

Reputation: 234807

You can use a StaticLayout to lay out your text into multiple lines that fit within a given width.

Upvotes: 1

Laurence Gonsalves
Laurence Gonsalves

Reputation: 143184

What you're looking for is called word wrapping. Search for "word wrap java" and you'll find some examples, like this one.

Upvotes: 1

Related Questions