This week's book giveaway is in the Programmer Certification forum.
We're giving away four copies of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 and have Jeanne Boyarsky & Scott Selikoff on-line!
See this thread for details.
Win a copy of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 this week in the Programmer Certification forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

How do we do a Text Wrap

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!

 
Ranch Hand
Posts: 218
VI Editor Ruby Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is one way of doing it.

Hope that helps.
 
Author
Posts: 164
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
There is no beard big enough to make me comfortable enough with my masculinity to wear pink. Tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!