- 浏览: 382356 次
- 性别:
- 来自: 北京
最新评论
-
liuzhongzhou2721:
不错啊
Snmp4j编程简介之三:Snmp -
ahong520:
我在Keystore.getInstance("JK ...
java实现 SSL双向认证 -
tanghanlin:
好吧,还是支持下
Snmp4j编程简介之三:Snmp -
sjp524617477:
mark
java实现 SSL双向认证 -
dikesky:
您好,看了您的这篇文章学到很多东西。希望您提供一个QQ号(发到 ...
httpclient笔记(二)
The ftp4j library implements a Java full-features FTP client. With ftp4j embedded in your application you can: transfer files (upload and download), browse the remote FTP site (directory listing included), create, delete, rename and move remote directories and files.
ftp4j类库可支持实现java版的FTP客户端,可应用到你的应用程序中,实现文件的上传下载,浏览远程FTP服务器上的目录和文件,创建、删除、重命,移动远程目录和文件等操作。
ftp4j的特点:
1、100%免费
2、可远程连接FTP服务器
3、远程操作
4、文件上传下载
5、异常捕获
下载路径:http://www.sauronsoftware.it/projects/ftp4j/ftp4j-1.3.1.zip
快速上手:
The main class of the library is FTPClient (it.sauronsoftware.ftp4j.FTPClient).
Start creating a FTPClient instance:
FTPClient client = new FTPClient();
Connect now to a remote FTP service:
client.connect("ftp.host.com");
If the service port is other than the standard 21:
client.connect("ftp.host.com", port);
In example:
client.connect("ftp.host.com", 8021);
Step now to the login procedure:
client.login("carlo", "mypassword");
If no exception is thrown you are now authenticated to the remote server. Otherwise, if the authentication attempt fails, you receive a it.sauronsoftware.ftp4j.FTPException.
Anonymous authentication, if admitted by the connected service, can be done sending the username "anonymous" and an arbitrary password (note that some servers require an e-mail address in place of the password):
client.login("anonymous", "ftp4j");
Do anything you want with the remote FTP service, then disconnect:
client.disconnect(true);
This one sends the FTP QUIT command to the remote server, requesting a legal disconnect procedure. If you just want to break the connection, without sending any advice to the server, call:
client.disconnect(false);
Connecting through a proxy
The client connects to the server through a connector (an object implementing the it.sauronsoftware.ftp4j.FTPConnector interface), which returns to the client an already open connection (an object implementing the it.sauronsoftware.ftp4j.FTPConnection interface). That is why ftp4j could support a large set of proxies.
The connector for a client instance can be setted with the setConnector() method, obviously before connecting the remote server:
client.setConnector(anyConnectorYouWant);
Browsing the remote site
Get the current directory absolute path calling:
String dir = client.currentDirectory();
Change directory with:
client.changeDirectory(newPath);
You can use both absolute and relative paths:
client.changeDirectory("/an/absolute/one"); client.changeDirectory("relative");
Back to the parent directory with:
client.changeDirectoryUp();
Renaming files and directories
To rename a remote file or directory:
client.rename("oldname", "newname");
Moving files and directories
The rename() method can also be used to move files and directories from a location to another.
In example, think in the current working directory you have a file called "myfile.txt", and you want to move it in the sub-directory "myfolder":
client.rename("myfile.txt", "myfolder/myfile.txt");
Deleting files
To delete a remote file call:
client.deleteFile(relativeOrAbsolutePath);
In example:
client.deleteFile("useless.txt");
Creating and deleting directories
You can create a new directory on the remote site, if the service gives you this oppurtunity:
client.createDirectory("newfolder");
You can also remove an existing one:
client.deleteDirectory(absoluteOrRelativePath);
In example:
client.deleteDirectory("oldfolder");
Please note that usually FTP servers can delete only empty directories.
Downloading and uploading files
The easiest way to download a remote file is a call to the download(String, File) method:
client.download("remoteFile.ext", new java.io.File("localFile.ext"));
To upload:
client.upload(new java.io.File("localFile.ext"));
参考文章路径:http://www.sauronsoftware.it/projects/ftp4j/manual.php#3
发表评论
-
OpenNMS® 安裝指南
2011-03-10 16:20 1843THIS DOCUMENT IS FOR OpeNNMS 1. ... -
OSGI学习笔记(三)
2010-09-09 11:08 1149OSGi依赖性管理 OSGi允许您把您的应用程序分成多个模 ... -
OSGI学习笔记(二)
2010-09-09 11:03 1484开发一个简单的Hello World的OSGi Bundle( ... -
OSGI学习笔记(一)
2010-09-09 10:43 1157OSGi是什么 OSGi亦称做Java语言的动态模块系统,它 ... -
Javarebel小试
2010-09-07 16:49 33431 Javarebel简介 JavaRebel是一个JV ... -
240多个jQuery插件下载地址
2009-08-11 17:24 11967概述 jQuery 是继 prototype 之后又一个优秀 ... -
关于SNMP的RFC文档号
2009-05-04 16:10 4550一. SMIv1Full Standards: ... -
JavaCard CPU的设计与FPGA实现
2009-05-04 14:28 21961 JavaCard简介 智能 ... -
Java Card 技术(三)
2009-05-04 14:17 2604Java Card 应用程序的元素 请记住,Java ... -
Java Card 技术(二)
2009-05-04 14:13 2713本系列文章的第 1 部分介绍了 Java Card 技术的 ... -
Extjs学习笔记(一)
2008-12-15 13:39 1598下载extj :http://extjs.com/deploy ... -
James学习笔记
2008-11-25 15:13 3369Apache James 简称 James, 是 Java ... -
非阻塞的Socket链接(来自老紫竹)
2008-11-25 11:10 1712import java.io.IOException; ... -
java实现 SSL双向认证
2008-11-24 16:36 31186实现技术:JSSE(Java Security Socket ... -
编码传说
2008-11-21 17:38 1298很久很久以前,有一群人,他们决定用8个可以开合的晶体管来 ... -
使用Log4j进行日志操作
2008-10-16 11:36 1108使用Log4j进行日志操作1. 概述1.1. 背景在应用程序中 ... -
linux 下cpu 内存 磁盘 jvm的使用监控
2008-07-24 13:50 2913java 监控linux CPU 内存 磁盘 JVM: imp ... -
snmp4j获取数据agent实例(三)
2008-07-03 11:43 6686agent代理端例子: import java.util. ... -
snmp4j获取数据实例(二)之SnmpTrap示例
2008-07-03 10:27 6586snmp4j的jar包可以在它的官方网站http://www. ... -
snmp4j获取数据实例(一,Linux SNMP OID’s for CPU,Memory a)
2008-07-03 09:10 9037常用SNMP OID Linux SNMP OID’s f ...
相关推荐
Ftp4j.jar 包用于开发FTp应用
(不过如果你需要FTPS及SFTP,那ftp4j不支持) jar包只有50多k,地址在这里:ftp4j 使用代理的代码: import java.util.ArrayList; import it.sauronsoftware.ftp4j.FTPClient; import it.sauronsoftware.ftp4j....
ftp4j是一个FTP客户端Java类库,实现了FTP客户端应具有的大部分功能。可以将ftp4j嵌到你的Java应用中,来传输文件(包括上传和下载),浏览远程FTP服务器上的目录和文件,创建、删除、重命,移动远程目录和文件。ftp...
android的ftp4j的jar包
FTP(File Transfer Protocol,文件传输协议) 是 TCP/IP 协议组中的协议之一。FTP协议包括两个组成部分,其一为FTP服务器,其二为FTP客户端。其中FTP服务器用来存储文件,用户可以使用FTP客户端通过FTP协议访问位于...
ftp4j修改版,修正了ftp4j版本在Android终端上释放ftp连接异常的问题
可用的ftp4j-1.7.2jar包 , 压缩包解压,提取jar包直接使用,
ftp4j 1.5 manual.chm
将ftp4j JAR文件添加到你应用程序的classpath中, 然后你就可以自动启用ftp4j类的使用了.
ftp4j是一个FTP客户端Java类库,实现了FTP客户端应具有的大部分功能。可以将ftp4j嵌到你的Java应用中,来传输文件(包括上传和下载),浏览远程FTP服务器上的目录和文件,创建、删除、重命,移动远程目录和文件。ftp...
FTP客户端Java类库 ftp4j
FTP工具类(ftp4j)的各个方法的使用说明。
android 使用ftp上传下载(使用ftp4j)弹出框(显示上传下载进度条) 只是客户端
ftp4j-1.5.1.zip j-ftp-1.52.tar.gz jsch-0.1.43.zip ftp4j-1.5.1.zip j-ftp-1.52.tar.gz jsch-0.1.43.zip
ftp4j-1.4.1.jarftp4j-1.4.1.jarftp4j-1.4.1.jarftp4j-1.4.1.jarftp4j-1.4.1.jarftp4j-1.4.1.jarftp4j-1.4.1.jarftp4j-1.4.1.jar
ftp4j源码,可以参考这个做ftps的客户端。
完整的帮助文档,中文帮助文档,ftp4j jar包 自己写的一个完整的上传实例。
基于java的开发源码-FTP客户端Java类库 ftp4j.zip 基于java的开发源码-FTP客户端Java类库 ftp4j.zip 基于java的开发源码-FTP客户端Java类库 ftp4j.zip 基于java的开发源码-FTP客户端Java类库 ftp4j.zip 基于java的...
ftp4j-1.7.2.jar支持FTPClient上传以及下载等功能。
ftp4j类库可支持实现java版的FTP客户端,可应用到你的应用程序中,实现文件的上传下载,浏览远程FTP服务器上的目录和文件,创建、删除、重命,移动远程目录和文件等操作。 ftp4j的特点: 1、100%免费 2、可远程连接...