(二)、edtFTPj FileTransferClient
来源:互联网 发布:人工智能时代的危机 编辑:程序博客网 时间:2024/05/21 13:37
edtFTPj的FileTransferClient类简单易用,而且下载的组件包中文档丰富,参考使用,完全能满足自己需要。
下载地址为:http://www.enterprisedt.com/index.html
废话不多说,上代码:
- public class EdtFtpFreeTest {
- public static void main(String[] args) {
- String ftp_url = "127.0.0.1";
- String ftp_username = "username";
- String ftp_password = "password";
- String ftp_path = "remote path";
- // 本地文件路径
- String file_path = "local path name";
- //上传服务器上文件名
- String remoteFile = "remote file name";
- FileTransferClient ftp = new FileTransferClient();
- try {
- ftp.setRemoteHost(ftp_url);
- ftp.setUserName(ftp_username);
- ftp.setPassword(ftp_password);
- ftp.connect();
- ftp.setContentType(FTPTransferType.BINARY);
- ftp.changeDirectory(ftp_path);
- //直接上传
- ftp.uploadFile(file_path, remoteFile, WriteMode.RESUME);
- //构造文件流上传
- OutputStream os = ftp.uploadStream(remoteFile);
- FileInputStream is = new FileInputStream(file_path);
- byte[] bytes = new byte[1024];
- int c;
- while ((c = is.read(bytes)) != -1) {
- os.write(bytes, 0, c);
- }
- is.close();
- os.close();
- is = null;
- os = null;
- ftp.disconnect();
- } catch (FTPException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
public class EdtFtpFreeTest {public static void main(String[] args) {String ftp_url = "127.0.0.1";String ftp_username = "username";String ftp_password = "password";String ftp_path = "remote path";// 本地文件路径String file_path = "local path name";//上传服务器上文件名String remoteFile = "remote file name";FileTransferClient ftp = new FileTransferClient();try {ftp.setRemoteHost(ftp_url);ftp.setUserName(ftp_username);ftp.setPassword(ftp_password);ftp.connect();ftp.setContentType(FTPTransferType.BINARY);ftp.changeDirectory(ftp_path);//直接上传ftp.uploadFile(file_path, remoteFile, WriteMode.RESUME);//构造文件流上传OutputStream os = ftp.uploadStream(remoteFile);FileInputStream is = new FileInputStream(file_path);byte[] bytes = new byte[1024];int c;while ((c = is.read(bytes)) != -1) {os.write(bytes, 0, c);}is.close();os.close();is = null;os = null;ftp.disconnect();} catch (FTPException e) {e.printStackTrace();} catch (IOException e) {e.printStackTrace();}}}
- (二)、edtFTPj FileTransferClient
- edtftpj
- ftp客户端编程--edtftpj
- edtftpj 2.0.1开源包扩展
- edtFTPj通过代理上传文件的演示
- 用edtftpj实现Java FTP客户端工具
- 利用edtftpj组件实现FTP文件的上传
- 利用edtftpj组件实现FTP文件的上传。
- 使用edtftpj进行ftp文件上传和下载
- 增强的Java FTP工具----扩展免费版的edtftpj
- edtFTPj/PRO 4.0 发布,Java 的 FTP 类库
- edtftpj让Java上传FTP文件支持断点续传
- edtftpj让Java上传FTP文件支持断点续传
- 用edtftpj实现ftp文件上传和下载
- (二)
- (二)
- 二
- 《二》
- 检查所有运行的进程,关闭某个指定的进程
- 在Javascript中管理你的Cookie
- BPO是什么?
- Linux网络安全策略和保护措施
- (一)、Sun FtpClient
- (二)、edtFTPj FileTransferClient
- 我的构思------启光一好
- windows mobile 刷新 rom
- 鼠标单击变双击问题
- JAVA中图片上传资料
- 泡m英文必备
- C# 正则替换文本为超链接
- Hibernate检索策略
- 什么是集群?