Merge pull request #399 from fredericBregier/3

Proposal to fix issue #398 by replacing transferTo by using loop on FileChannel
This commit is contained in:
Frédéric Brégier 2012-06-15 03:04:34 -07:00
commit 6d29d2feb1

View File

@ -289,10 +289,17 @@ public abstract class AbstractDiskHttpData extends AbstractHttpData {
FileOutputStream outputStream = new FileOutputStream(dest);
FileChannel in = inputStream.getChannel();
FileChannel out = outputStream.getChannel();
long destsize = in.transferTo(0, size, out);
int chunkSize = 8196;
long position = 0;
while (position < size) {
if (chunksize < size - position) {
chunksize = size - position;
}
position += in.transferTo(position, chunkSize , out);
}
in.close();
out.close();
if (destsize == size) {
if (position == size) {
file.delete();
file = dest;
isRenamed = true;