The secret of how to be miserable is to constantly expect things are going to happen the way that they are "supposed" to happen.
You can have faith, which carries the understanding that you may be disappointed. Then there's being a willfully-blind idiot, which virtually guarantees it.
Tim Holloway wrote:You've got 2 possible strategies here. One is to use a scanner to break the text down into tokens and keep appending tokens into a StringBuilder until you reach the limit, then output the StringBuilder contents as a String. Reset the StringBuilder to empty and start appending from there. There really isn't anything more primitive that StringBuilder in Java.
All things are lawful, but not all things are profitable.
Knute Snortum wrote:Just a thought (and I having tried it), I don't think any of these solutions handle when a "word" is longer than the maximum characters per line.
The secret of how to be miserable is to constantly expect things are going to happen the way that they are "supposed" to happen.
You can have faith, which carries the understanding that you may be disappointed. Then there's being a willfully-blind idiot, which virtually guarantees it.
Paul Clapham wrote:This sounds like something I did a long time ago. I can't track it down now, maybe it was for work but I don't think so. Anyway I used (or thought of using) a java.text.BreakIterator which sounds a lot like your requirement.
Tim Holloway wrote:Although assuming your output lines are a civilized length (60 characters or so), the English language doesn't have a lot of potential offenders and therefore syllable-backtracking isn't likely to be worth it.
All things are lawful, but not all things are profitable.
Knute Snortum wrote:
Tim Holloway wrote:Although assuming your output lines are a civilized length (60 characters or so), the English language doesn't have a lot of potential offenders and therefore syllable-backtracking isn't likely to be worth it.
Well, I was thinking of very-long-over-hyphenated-pseudo-adjectives or a list like Democrat/Republican/Independent/Green/Pacific/Socialist/Communist, any list of words that don't have spaces between them.
The secret of how to be miserable is to constantly expect things are going to happen the way that they are "supposed" to happen.
You can have faith, which carries the understanding that you may be disappointed. Then there's being a willfully-blind idiot, which virtually guarantees it.
This one time, at bandcamp, I had relations with a tiny ad.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
|