apache-comnons系列之commons-net3.6 学习笔记

原创 2017年07月30日 22:46:47

apache-comnons系列之commons-net3.6 学习笔记



  • The SocketClient provides the basic operations that are required of client objects accessing sockets.


  • FTP provides the basic the functionality necessary to implement your own FTP client. It extends org.apache.commons.net.SocketClient since
  • extending TelnetClient was causing unwanted behavior (like connections that did not time out properly)
  • FTPClient encapsulates all the functionality necessary to store and retrieve files from an FTP server. This class takes care of all
  • low level details of interacting with an FTP server and provides a convenient higher level interface.


  • The DiscardTCPClient class is a TCP implementation of a client for the Discard protocol described in RFC 863.
  • The EchoTCPClient class is a TCP implementation of a client for the Echo protocol described in RFC 862.


  • ProtocolCommandSupport is a convenience class for managing a list of ProtocolCommandListeners and firing ProtocolCommandEvents. You can
  • simply delegate ProtocolCommandEvent firing and listener registering/unregistering tasks to this class.
  • Object __source;
  • ListenerList __listeners


  • There exists a large class of IETF protocols that work by sending an ASCII text command and arguments to a server, and then receiving an ASCII text reply.


  • EventListener


  • The FTPFile class is used to represent information about files stored on an FTP server.


  • FTPFileEntryParser defines the interface for parsing a single FTP file listing and converting that information into an {@link org.apache.commons.net.ftp.FTPFile} instance.


  • Implementation FTPFileEntryParser and FTPFileListParser for standardUnix Systems.


  • Implements some simple FTPFileFilter classes.


  • org.apache.commons.net.SocketClientTest
    • protected int timeout—-The timeout to use after opening a socket
    • protected Socket socket—-The socket used for the connection.
    • protected InputStream input—-The socket’s InputStream.
    • protected OutputStream output—-The socket’s OutputStream.
    • protected SocketFactory socketFactory—-The socket’s SocketFactory.
    • protected ServerSocketFactory serverSocketFactory—-The socket’s ServerSocket Factory.
    • connect
      • Opens a Socket connected to a remote host at the specified port and originating from the current host at a system assigned port.
      • Before returning, {@link #connectAction connectAction() } is called to perform connection initialization actions.
    • connectAction
      • input = socket.getInputStream();
      • output = socket.getOutputStream();
    • disconnect
      • Disconnects the socket connection.
      • closeQuietly
  • FtpTest
    • protected BufferedReader controlInput—-Wraps SocketClient.input to facilitate the reading of text from the FTP control connection.
    • protected BufferedWriter controlOutput—-Wraps SocketClient.output to facilitate the writing of text to the FTP control connection.
    • replyCode/_replyLines/_newReplyString/_commandSupport
    • connectAction
      • controlInput =new CRLFLineReader(new InputStreamReader(input, getControlEncoding()));
      • controlOutput =new BufferedWriter(new OutputStreamWriter(output, getControlEncoding()));
    • sendCommand
      • Sends an FTP command to the server, waits for a reply and returns the numerical response code
      • __buildMessage
      • __send
        • controlOutput.write(message);
        • controlOutput.flush();
        • fireCommandSent
        • If there are any listeners, send them the command details./事件监听处理发送事件
        • getCommandSupport().fireCommandSent(command, message);
        • __getReply
        • String line = controlInput.readLine();/等待命令返回信息
        • _replyLines.add(line);
        • fireReplyReceived
      • fireReplyReceived
      • If there are any listeners, send them the reply details./事件监听处理返回信息
      • getCommandSupport().fireReplyReceived(replyCode, reply);
  • org.apache.commons.net.ftp.FTPClientTest/examples.ftp.FTPClientExample
    • private int __dataConnectionMode—-决定数据传输时的初始化动作由服务器还是客户端进行初始化
    • __initDefaults
      • __dataConnectionMode = ACTIVE_LOCAL_DATA_CONNECTION_MODE;(数据传输由服务器进行初始化)
    • login
      • Login to the FTP server using the provided username and password.
    • user
      • A convenience method to send the FTP USER command to the server,receive the reply, and return the reply code.
      • FTPCmd.USER
    • pass
      • A convenience method to send the FTP PASS command to the server,receive the reply, and return the reply code
      • FTPCmd.PASS
    • storeFile
      • Stores a file on the server using the given name and taking input from the given InputStream.
      • _storeFile
        • openDataConnection
          • if (__dataConnectionMode == ACTIVE_LOCAL_DATA_CONNECTION_MODE)
          • port(getReportHostAddress(), server.getLocalPort())
          • socket = server.accept();
          • else
          • socket = socketFactory.createSocket();
        • Util.copyStream
        • completePendingCommand()
    • retrieveFile
      • Retrieves a named file from the server and writes it to the given OutputStream.
      • _retrieveFile
        • openDataConnection
        • Util.copyStream
        • completePendingCommand();
    • listFiles
      • Using the default system autodetect mechanism, obtain a list of file information for the current working directory.
      • 依赖解析引擎按照指定的解析格式和过滤器选出需要的文件列表
      • FTPListParseEngine engine = initiateListParsing((String) null, pathname);
      • engine.getFiles()

Apache Commons Math3学习笔记(1)- 快速傅立叶变换

傅立叶变换:org.apache.commons.math3.transform.FastFourierTransformer类。 用法示例代码: double inputData = new d...
  • kingfox
  • kingfox
  • 2015年03月07日 17:14
  • 4836

Commons Math学习笔记

先列出一个目录:(这个目录是根据commons math 2.1库的结构设计的) Section 1 linear 线性代数(矩阵为主) 1) Vector 向量 2) Matrix...
  • jiutianhe
  • jiutianhe
  • 2014年11月21日 15:37
  • 13850

Apache Commons Math3学习笔记(3) - 数值积分

  • kingfox
  • kingfox
  • 2015年03月09日 13:13
  • 4857

apache-comnons系列之commons-vfs2 学习笔记

apache-comnons系列之commons-vfs2 学习笔记概述 参考 http://p7engqingyang.iteye.com/blog/1702429 http://blog.csd...
  • undergrowth
  • undergrowth
  • 2017年08月09日 00:30
  • 460

apache-comnons系列之commons-logging1.2 学习笔记

apache-comnons系列之commons-logging1.2 学习笔记概述 参考 http://blog.csdn.net/linshuhe1/article/details/537615...
  • undergrowth
  • undergrowth
  • 2017年08月06日 14:29
  • 165

apache-comnons系列之commons-pool2.4 学习笔记

apache-comnons系列之commons-pool2.4 学习笔记概述 参考 http://www.jianshu.com/p/b0189e01de35 https://my.oschina...
  • undergrowth
  • undergrowth
  • 2017年07月29日 16:14
  • 234

apache-comnons系列之commons-configuration2 学习笔记

apache-comnons系列之commons-configuration2 学习笔记概述 参考 http://blog.csdn.net/werder/article/details/54562...
  • undergrowth
  • undergrowth
  • 2017年08月05日 21:18
  • 685

apache-comnons系列之commons-email1.4 学习笔记

apache-comnons系列之commons-email1.4 学习笔记概述Email The base class for all email messages. This class set...
  • undergrowth
  • undergrowth
  • 2017年07月29日 23:56
  • 229

apache-comnons系列之commons-dbutils1.7 学习笔记

apache-comnons系列之commons-dbutils1.7 学习笔记概述 参考 http://blog.csdn.net/imust_can/article/details/700597...
  • undergrowth
  • undergrowth
  • 2017年07月26日 00:17
  • 517

Apache Commons Math3学习笔记(3) - 数值积分

  • kingfox
  • kingfox
  • 2015年03月09日 13:13
  • 4857
您举报文章:apache-comnons系列之commons-net3.6 学习笔记