通过顺藤摸瓜的研究,现在代码的焦点集中在写线程中的下面这个方法:
org.apache.commons.net.io.Util.copyStream(remoteInput, localOutput);
再往里面跟踪,发现Util里面有几个copyStream的重载方法,归根结底,最终调用的是这个方法:
/***************************************************************************
* Copies the contents of an InputStream to an OutputStream using a copy
* buffer of a given size and notifies the provided CopyStreamListener of
* the progress of the copy operation by calling its bytesTransferred(long,
* int) method after each write to the destination. If you wish to notify
* more than one listener you should use a CopyStreamAdapter as the listener
* and register the additional listeners with the CopyStreamAdapter.
* <p>
* The contents of the InputStream are read until the end of the stream is
* reached, but neither the source nor the destination are closed. You must
* do this yourself outside of the method call. The number of bytes
* read/written is returned.
* <p>
*
* @param source
* The source InputStream.
* @param dest
* The destination OutputStream.
* @param bufferSize
* The number of bytes to buffer during the copy.
org.apache.commons.net.io.Util.copyStream(remoteInput, localOutput);
再往里面跟踪,发现Util里面有几个copyStream的重载方法,归根结底,最终调用的是这个方法:



















