public void writeTo(BufferedSink sink)
throws IOException
{
if (this.data != null) {
sink.write(this.data);
} else {
long read;
long total = 0;
while ((read = source.read(sink.buffer(), SEGMENT_SIZE)) != -1) {
total += read;
sink.flush();
mba.raiseEventFromDifferentThread(this, this, 0, EN+"_writeprogress", false, new Object[]{total,contentLength});
//this.listener.transferred(total);
// if (mba.subExists(EN+"_writeprogress")) {
// mba.raiseEvent(this, EN+"_writeprogress", new Object[]{total,contentLength});
//
// }
}
//Util.closeQuietly(source);
}
}