fork(1) download
  1. import java.util.*;
  2. import java.util.regex.*;
  3. import static java.util.stream.Collectors.*;
  4.  
  5. class Ideone {
  6. public static void main (String[] args) {
  7. String s = "Many things went on at the Unseen University and, regrettably teaching had to be one of them. The faculty had long ago confronted this fact and had perfected various devices for avoiding it.";
  8. List<String> lines = Pattern.compile(".{80}[^ ]* |.*").matcher(s).results().map(MatchResult::group).collect(toList());
  9. lines.forEach(System.out::println);
  10. }
  11. }
Success #stdin #stdout 0.1s 48840KB
stdin
Standard input is empty
stdout
Many things went on at the Unseen University and, regrettably teaching had to be 
one of them. The faculty had long ago confronted this fact and had perfected various 
devices for avoiding it.