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

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

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

概述

SocketClient

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

FTP

  • 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
  • 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.

DiscardTCPClient

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

ProtocolCommandSupport

  • 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

ProtocolCommandEvent

  • 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.

ProtocolCommandListener

  • EventListener

FTPFile

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

FTPFileEntryParser

  • 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.

UnixFTPEntryParser

  • Implementation FTPFileEntryParser and FTPFileListParser for standardUnix Systems.

FTPFileFilters

  • 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 Math的简介和使用

apache commons Math是一组偏向科学计算为主的函数,主要是针对线性代数,数学分析,概率和统计等方面。      我虽然是数学专业毕业,当年也是抱着《数学分析》啃,但是好久不用,这些概...
  • ffm83
  • ffm83
  • 2014-12-24 16:35
  • 5407

java实现FTP上传下载:FTPClient类进行FTP上传下载大文件(包含导致假死现象)

1.首先,程序中设置ftp请求方式为被动模式,即程序去请求ftp服务器,要求服务器来打开一个端口,让客户端传输文件。这是基本的,但是无法避免上传阻塞问题。 2.其次,设置连接超时,数据传输超时等等,也...

利用Apache commons net 包实现FTP上传和下载

在使用这个方法之前,要做一些准备工作。首先要有一个能用的FTP服务,并且有能够上传下载的账户。 不同的操作系统可能会有一些路径上的差异,需要注意。 下面的代码包括 FTP登陆,上传文件,上传文件夹...
  • ffm83
  • ffm83
  • 2014-12-25 11:54
  • 2211

apache commons JXPath 说明,使用JXPath访问java对象、集合和XML文件

Commons-JXPath 提供了使用Xpath语法操纵符合Java类命名规范的 JavaBeans的工具。也支持 maps, DOM 和其他对象模型。JXPath的主要功能在于一组java类库来使...
  • ffm83
  • ffm83
  • 2014-12-24 16:04
  • 1144

房屋租赁门户站

<script type="text/javascript"sr

使用apache的commons-net-3.1.jar实现FTP上传

commons-net-3.1.jar下载地址 在有些项目中我们需要将文件保存在FTP中, 但是在网上介绍FTP上传的知识总是感觉很混乱, 现在将网上的一些代码经过整理与测试,拿出来与大家分享。...

java用FTP实现上传、下载文

FTPClient的jar包下载地址: http://commons.apache.org/proper/commons-net/download_net.cgi 文件上传: public stati...

Commons net实现 FTP上传下载

最近项目中需要到Ftp文件上传,选择了Commons net。Commons net包中的ftp工具类能够帮助我们轻松实现Ftp方式的文件上传/下载。其中最重要的一个类就是FTPClient类,这个提...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)