@Override public void close() throws IOException { if (totalRead == fileSize) { callback.finish(); } else { callback.failed(); } super.close(); }
@Override public int read(byte[] b) throws IOException { int bytesRead = super.read(b); totalRead += bytesRead; callback.update(totalRead); return bytesRead; }
@Override public int available() throws IOException { int available = super.available(); if (available == 0) { callback.finish(); } return available; }