Permalink
Browse files

Don't make a copy of the buffer, as it may shrink down to one elemnent.

Also, use a bufferedoutputstream.
  • Loading branch information...
jghoman committed Jul 28, 2012
1 parent 36bd7f1 commit 40a3d99a2323f65d3ba95050ca329047705b812b
@@ -16,6 +16,7 @@
package voldemort.store.readonly.fetcher;
+import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
@@ -200,16 +201,16 @@ private void copyFileWithCheckSum(FileSystem fs,
OutputStream output = null;
try {
input = fs.open(source);
- output = new FileOutputStream(dest);
+ output = new BufferedOutputStream(new FileOutputStream(dest));
byte[] buffer = new byte[bufferSize];
while(true) {
int read = input.read(buffer);
if(read < 0) {
break;
- } else if(read < bufferSize) {
- buffer = ByteUtils.copy(buffer, 0, read);
+ } else {
+ output.write(buffer, 0, read);
}
- output.write(buffer);
+
if(fileCheckSumGenerator != null)
fileCheckSumGenerator.update(buffer);
if(throttler != null)

0 comments on commit 40a3d99

Please sign in to comment.