FTP客户端的设计与实现铜陵学院《计算机网络》课程设计设计题目:FTP客户端的设计与实现系别数学与计算机科学院班级11计算机本(2)学生姓名施德磊学号1106111111学生姓名李煜学号1106111100学生姓名殷晨晨学号1106111161学生姓名李新年学号1106111147学生姓名张强学号1106111131学生姓名林黄灿学号1106111102指导教师汪永生职称讲师起止日期:2013年12月15日起——2013至12年20月日止FTP客户端的设计与实现第1页共23页目录第一章序言·················································································································21.1研究背景·························································································21.2开发工具·························································································2第二章系统需求分析·······························································································22.1功能需求·························································································22.2系统模型设计···················································································32.3系统工作流程设计·············································································3第三章系统设计·········································································································43.1实现功能·························································································43.2函数说明·························································································43.2.1界面设计代码·····················································································43.2.2功能实现函数·····················································································9第四章系统实现·······································································································134.1界面设计的实现················································································134.1.1连接服务器·······················································································134.1.2获取文件列表······························································错误!未定义书签。4.1.3断开服务器·······················································································144.1.4上传文件···························································································154.1.5下载·································································································174.1.6重命名···························184.1.7删除····························194.1.8刷新····························20总结························································································································21参考文献···················································································································21FTP客户端的设计与实现第2页共23页第一章序言摘要FTP是Internet上用来传送文件的协议。它是为了我们能够在Internet上互相传送文件而制定的文件传送标准,规定了Internet上文件如何传送。通过FTP协议,我们就可以跟Internet上的FTP服务器进行文件的上传或下载。本文以实现一个简单易用的FTP客户端为目标,通过分析FTP协议的基本工作原理和FTP的数据传输原理,研究如何使用Java工具对FTP客户端进行设计,选择Java类库中的ftpclient类来实现FTP客户端程序的上传下载等主要功能,并用Jbuilder2006软件提供的一个支持可视化编程的开发环境,从而实现了对FTP客户端的开发.关键词:FTP协议、工作原理、ftpclient、上传下载1.1研究背景FTP是Internet上最早也是最广的应用,直到今天它仍是最重要和最基本的应用之一。用FTP将信息下载到本地是一件十分普遍的事。也随之出现了许多下载软件。尽管远程登录(Telnet)提供了访问远程文件的极好方法,但怎么也比不上使用自己计算机中的文件方便。如果用户想使用其它计算机上的文件,最理想的方法就是把它COPY到自己的计算机中,以便在本地计算机上操作。FTP正是完成这项工作的工具,你可以在任意一个经过文件传输协议(FTP)访问的公共有效的联机数据库或文档中找到你想要的任何东西。传统的数据库应用系统采用的是客户机/服务器(Client/Server)模式,有高度的交互性,高效的用户界面等优点.1.2开发工具Java编程语言,Java编程语言的主要特性是个简单、面向对象、分布式解释性、健壮、安全与系统无关、可移植、高性能、多线程和动态的语言。第二章系统需求分析2.1功能需求FTP客户端的设计与实现第3页共23页1.实现一个图形用户界面的FTP客户端,保证文件的安全传输和存储。2.通过输入服务器地址、用户名和密码、可以实现远程FTP主机的登录。3.提供本地文件的上传功能,可对FTP主机文件进行下载、上传、删除、重命名等文件操作。2.2系统模型设计图2.2FTP的基本模型2.3系统工作流程设计控制进程数据传送进程用户接口命令与应答控制连接数据连接文件传输数据传送进程控制进程服务器客户端客户端用户登录登录验证操作内容列表查看文件列表连接成功至服务器端上传文件重命名文件上翻文件列表删除文件下翻文件列表下载文件文件管理连接失败退出FTP客户端的设计与实现第4页共23页第三章系统设计3.1实现功能用户登陆用户退出文件上传文件下载文件重命名文件删除上翻文件目录下翻文件目录界面实现部分:设计为一个用户界面,上面包括各种用户按钮、文本输入栏、状态栏等等。具体如下:服务器地址信息输入栏、端口信息输入栏、用户名、密码输入栏、用户登陆(连接)按钮、用户退出(断开连接)按钮、服务器文件显示列表框、下载文件按钮、上传文件按钮、重命名文件按钮、删除文件按钮、上一级目录按钮,下一级目录按钮,状态栏。3.2函数说明3.2.1界面设计代码每个按钮对象注册监听器对应相关的业务逻辑,调用FtpBean类中的对应方法。下面是页面部分实现的主要代码以及相关说明:packageftp;importjava.awt.event.*;importjava.awt.*;importjava.util.*;importjava.util.List;importjava.util.StringTokenizer;importjava.io.*;importjavax.swing.*;importjavax.swing.event.*;publicclassFTPextendsJFrame{FTP客户端的设计与实现第5页共23页FtpBeanftp=newFtpBean();//FTP客户端对象privateFileWriterwrite;privatePrintWriterout;privateDatetime;privateJTextFieldurl=newJTextField();//FTP服务器地址privateJTextFieldport=newJTextField();//FTP服务器端口privateJTextFieldusername=newJTextField();//用户名privateJTextFieldpassword=newJTextField();//密码privateJTextFieldstatus=newJTextField();//当前状态privateJButtonconnectButton=newJButton(连接);//连接按钮privateJButtoncloseButton=newJButton(断开连接);//断开连接按钮privateJPopupMenupopup=newJPopupMenu();;privateJMenuItemrefresh=newJMenuItem(刷新);//右键弹出菜单privateJMenuItemdelete=newJMenuItem(删除);privateJMenuItemdownload=newJMenuItem(下载);privateJMenuItemupload=newJMenuItem(上传);privateJMenuItemrename=newJMenuItem(重命名);privateJMenuItemupDir=newJMenuItem(上级目录);privateJMenuItemshowLog=newJMenuItem(显示日志信息);finalDefaultListModelm=newDefaultListModel();//显示文件列表JListfileList=newJList(m);JScrollPanefileScrollPane;privateDimensionfaceSize=newDimension(400,600);//框架大小publicFTP(){init();createPopup();