java ftp怎么实现java ftp方式的断点续传

programmeraaron 2005-08-31 07:39:00
java ftp怎么实现java ftp方式的断点续传?
我是用:rivate FtpClient aftp;这个对象的

怎么断点续传知道吗?
...全文
773 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
kingofworl 2006-05-21
  • 打赏
  • 举报
回复
首先要ftp服务器支持
f_acme 2006-05-21
  • 打赏
  • 举报
回复
这个要看ftp的协议了
leonwu1981_2 2006-05-21
  • 打赏
  • 举报
回复
用socket向ftp服务器发送rest 1000命令,再发送pasv命令打开被动模式,接收新通道的数据后打开通道,在原通道中发送retr [文件名],ftp服务器就通过新通道从请求文件的1000个字符处传文件了
xiaozhumaomao 2006-05-21
  • 打赏
  • 举报
回复
up
yuyangzhi 2005-12-15
  • 打赏
  • 举报
回复
做过的人能不能具体说明一下实现方法,谢谢
CPPvip 2005-12-15
  • 打赏
  • 举报
回复
网上有一个HTTP的断点续传的可以去参考一下,不过它是通过HTTP协议去实现的,我也想知道FTP有没有这方面的协议,如果我想读那个文件从文件哪个长度开始读这样的协议.不过也可以参考一下开源的一些FTP的包它是怎么做的.
spook_l 2005-12-05
  • 打赏
  • 举报
回复
look
ftiger 2005-09-01
  • 打赏
  • 举报
回复
做个记号
programmeraaron 2005-09-01
  • 打赏
  • 举报
回复
用了RandomAccessFile,设置好当前起始地点后,直接传就可以续传了吗?还是说要对ftp对象设置什么属性
rainly1985 2005-08-31
  • 打赏
  • 举报
回复
同意 : jFresH_MaN(Contributing to Eclipse) 的观点
RandomAccessFile在这里很有用
sqlink 2005-08-31
  • 打赏
  • 举报
回复
import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPReply;

import java.io.*;

public class MyFTP {
private FTPClient ftp = new FTPClient();

public MyFTP() {
ftp.addProtocolCommandListener(new PrintCommandListener(new PrintWriter(System.out)));
}

public boolean connect(String hostname, int port, String username, String password) throws IOException {
ftp.connect(hostname, port);
if (FTPReply.isPositiveCompletion(ftp.getReplyCode())) {
if (ftp.login(username, password)) {
return true;
}
}
disconnect();
return false;
}

public boolean download(String remote, String local) throws IOException {
ftp.enterLocalPassiveMode();
boolean result;
File f = new File(local);
if (f.exists()) {
OutputStream out = new FileOutputStream(f, true);
ftp.setRestartOffset(f.length());
result = ftp.retrieveFile(remote, out);
out.close();
} else {
OutputStream out = new FileOutputStream(f);
result = ftp.retrieveFile(remote, out);
out.close();
}
return result;
}

public void disconnect() throws IOException {
if (ftp.isConnected()) {
ftp.disconnect();
}
}
}
bob_thb 2005-08-31
  • 打赏
  • 举报
回复
级别不够,我还要努力啊
jFresH_MaN 2005-08-31
  • 打赏
  • 举报
回复
一般断点续传的原理是用RandomAccessFile来访问需要传递的文件,然后因为这个类可以根据一个long值去从文件的某一点开始读写。所以你每次传的时候只要记住传到了什么位置,下次就继续传。
simon0512 2005-08-31
  • 打赏
  • 举报
回复
学习

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧