Skip to content

Instantly share code, notes, and snippets.

@MrChebik
Last active August 26, 2017 23:01
Show Gist options
  • Save MrChebik/eb8b4c4ca0006e2152e9047c445bf7f0 to your computer and use it in GitHub Desktop.
Save MrChebik/eb8b4c4ca0006e2152e9047c445bf7f0 to your computer and use it in GitHub Desktop.
public static void main(String[] args) {
final int[] pinger = {0};
System.out.println("WELL, PRINCE, so Genoa and Lucca are now just family estates of the Buonapartes. But I warn you, if you don't tell me that this means war, if you still try to defend the infamies and horrors perpetrated by that Antichrist I really believe he is Antichrist I will have nothing more to do with you and you are no longer my friend, no longer my 'faithful slave', as you call yourself! But how do you do? I see I have frightened you sit down and tell me all the news."
.trim().chars().mapToObj(i -> (char) i).collect(Collector.of(
(Supplier<List<String>>) ArrayList::new,
(array, ch) -> {
if (array.size() == 0) {
array.add("");
}
if (Character.isWhitespace(ch)) {
pinger[0] = 1;
} else {
if (pinger[0] == 1) {
array.add("");
pinger[0] = 0;
}
array.set(array.size() - 1, array.get(array.size() - 1) + ch);
}
},
(left, right) -> { left.addAll(right); return left; })));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment