Meaningless Drivel is fun!*
The moose likes Java in General and the fly likes How do we do a Text Wrap Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "How do we do a Text Wrap " Watch "How do we do a Text Wrap " New topic
Author

How do we do a Text Wrap

bob leduc
Greenhorn

Joined: Jan 20, 2003
Posts: 6
I want to wrap at 15 characters without chumping the words.
Eg: hello, could anyone help? It would be really appreciated.
result: >hello, could_
>anyone help?__
>It would be_
>really_
>appreciated.
this (_) signifies an empty space
It would be greatly appreciated if you can show me an example. Thanks again!
bob leduc
Greenhorn

Joined: Jan 20, 2003
Posts: 6
The functionality needed is as show below:
The original string:
The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog again. The quick brown fox jumps over the lazy dog one more time.
The string word wrapped at 40 characters:
The quick brown fox jumps over the lazy
dog. The quick brown fox jumps over the
lazy dog again. The quick brown fox
jumps over the lazy dog one more time.
Originally posted by bob leduc:
I want to wrap at 15 characters without chumping the words.
Eg: hello, could anyone help? It would be really appreciated.
result: >hello, could_
>anyone help?__
>It would be_
>really_
>appreciated.
this (_) signifies an empty space
It would be greatly appreciated if you can show me an example. Thanks again!
Wirianto Djunaidi
Ranch Hand

Joined: Mar 20, 2001
Posts: 210

Here is one way of doing it.

Hope that helps.
Dan Allen
Author
Ranch Hand

Joined: Mar 05, 2003
Posts: 164
One small change. If the break occurs at the end of a word, an extra space would preceed the following line. Take note to the updated code.


Dan Allen | http://mojavelinux.com | Author of Seam in Action - http://mojavelinux.com/seaminaction
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How do we do a Text Wrap