Extracted java code samples for async

Also ensured that files in Java are served as the docs say they are served,
as attachments, with a content length, not chunked.