final StopWatch sw = new StopWatch();
FileInputStream src = null;
final long nbytes;
try {
src = new FileInputStream(file);
FileChannel fc = src.getChannel();
String fileName = file.getName();
IOUtils.writeString(fileName, dos);
IOUtils.writeString(writeDirPath, dos);
long xferBytes = (count == -1L) ? fc.size() : count;
dos.writeLong(xferBytes);
dos.writeBoolean(append); // append=false
dos.writeBoolean(sync);
if(handler == null) {
dos.writeBoolean(false);
} else {
dos.writeBoolean(true);
handler.writeAdditionalHeader(dos);
}
// send file using zero-copy send
nbytes = fc.transferTo(fromPos, xferBytes, channel);
if(LOG.isDebugEnabled()) {
LOG.debug("Sent a file '" + file.getAbsolutePath() + "' of " + nbytes
+ " bytes to " + dstSockAddr.toString() + " in " + sw.toString());
}