File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes text formatting using java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "text formatting using java" Watch "text formatting using java" New topic

text formatting using java

Ryan Speller

Joined: Mar 01, 2008
Posts: 9
ok stuck on this one and looking for help

before i say a word heres what I have so far and what I need to do:

I think the comments sum up what I am doing, but I need help on the three TODO areas at the end.

Basically the end product should have you entering a text file and then formatting it according to maxWidth.

Started a new job this week 7am-6pm M-F so I am unbelievably exhausted and I just can't seem to figure out this last part and I know it should not be this hard.

Any help is appreciated, any help in the form of code is god-like.

Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46412
Go and find the "cattle drive" part of this website and find the example (I think 1a) which prints Gertrude 100 times. Several other people are struggling with a similar problem, or with the cattle drive example which prints Gertrude without going over the end of the line. Do a search of this forum for 1b; it was only a few days ago.

What you need is to count the length of your ************************** line, count the length of line you have got to print out already, and if there isn't enough space for the next word, go onto a new line.
Remember to allow for your spaces.
I agree. Here's the link:
subject: text formatting using java
It's not a secret anymore!