update java example to handle chunking/resume