I need to split a VERY long string in Java at every 132 characters. But here's the trick: I need to split the String at the last instance of a whitespace of the 132 characters. So it's possible that the new String may be less than 132 characters. You see, if I have a long sentence and the 132nd character is in the middle of a word, then I don't want to chop that word. Rather I'd like to capture the whole word. I can't go over 132 characters, but I can go under:
String x = "..... impossible to realize."
Let's say the 132nd character is after the 't' in the word "to". Now I don't want to split the 't' and 'o'. I'd rather stop after the workd "impossible" and begin the next line with "to".
Any expert out there than can help?