I had this crazy idea for implementing 80-character word wrapping, and it seems like it works fine so far:
private static final Pattern wrapRE = Pattern.compile(".{0,79}(?:\\S(?:-| |$)|$)");
private static String[] wordWrap(String str) {
List list = new LinkedList();
Matcher m = wrapRE.matcher(str);
while (m.find()) list.add(m.group());
return (String[]) list.toArray(new String[list.size()]);
}I wrote this while working on improvements to the joscar demo - it has command-line help now! The new stuff currently in CVS, and will be released with 0.9.4 along with iChat AV 2.0 voice/video chat support (at least the OSCAR parts) and some codability enhancements (like usability, but for developers using joscar).