File dest,
CopyStats stats,
CheckSumType checkSumType) throws Throwable {
CheckSum fileCheckSumGenerator = null;
logger.debug("Starting copy of " + source + " to " + dest);
FSDataInputStream input = null;
OutputStream output = null;
for(int attempt = 0; attempt < maxAttempts; attempt++) {
boolean success = true;
long totalBytesRead = 0;
boolean fsOpened = false;
try {
// Create a per file checksum generator
if(checkSumType != null) {
fileCheckSumGenerator = CheckSum.getInstance(checkSumType);
}
logger.info("Attempt " + attempt + " at copy of " + source + " to " + dest);
input = fs.open(source);
fsOpened = true;
output = new BufferedOutputStream(new FileOutputStream(dest));
byte[] buffer = new byte[bufferSize];
while(true) {
int read = input.read(buffer);
if(read < 0) {
break;
} else {
output.write(buffer, 0, read);
}