if (outstream == null) {
throw new IllegalArgumentException("Output stream may not be null");
}
boolean completed = false;
try {
broadcastProgressIfNeeded(PROGRESS_START);
int pos = 0, totalLen = mContent.length;
while (pos < totalLen) {
int len = totalLen - pos;
if (len > DEFAULT_PIECE_SIZE) {
len = DEFAULT_PIECE_SIZE;
}
outstream.write(mContent, pos, len);
outstream.flush();
pos += len;
broadcastProgressIfNeeded(100 * pos / totalLen);
}
broadcastProgressIfNeeded(PROGRESS_COMPLETE);
completed = true;
} finally {
if (!completed) {
broadcastProgressIfNeeded(PROGRESS_ABORT);
}
}