vertx.fileSystem().open(filename, new AsyncResultHandler<AsyncFile>() {
public void handle(AsyncResult<AsyncFile> ar) {
final AsyncFile file = ar.result;
final Pump pump = Pump.createPump(req, file.getWriteStream());
final long start = System.currentTimeMillis();
req.endHandler(new SimpleHandler() {
public void handle() {
file.close(new AsyncResultHandler<Void>() {
public void handle(AsyncResult<Void> ar) {
if (ar.exception == null) {
req.response.end();