Java 8 samples in documentation

Add Java 8 samples to the docs.

Also add lambda-friendly creation of StringChunks and ByteChunks, like in Comet and EventSource.

Extract code samples from the Java test docs (#2560 and #2561).