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:
commit
6d29d2feb1
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user