急急急,花最后的分求ftp上传下载组件及例子!(在线等!!!)

lantian1979 2003-10-17 07:37:06
我现在的程序用到ftp上传下载组件,我下载了enterprisedt组件,但是他的例子怎么也找不到!谁有上传下载的组件及例子,麻烦发给我,好吗,感激不尽!!!
我email:hy-qjl@163.com
...全文
48 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
seekmoon 2003-11-05
  • 打赏
  • 举报
回复
good
icecloud 2003-11-05
  • 打赏
  • 举报
回复
http://www.enterprisedt.com
他的例子写在了junit的测试用例中。
到src/..../ftp目录下的test中,看到不少testFTPClient等
那些就是例子
alexboyboy 2003-10-23
  • 打赏
  • 举报
回复
这个看看

//向FTP服务器上上传一个文件
String server="FTP服务器";
String user="登录名";
String password="登录密码";
String path="FTP路径";
String filename="要上传的文件";
try {
FtpClient ftpClient=new FtpClient();
ftpClient.openServer(server);
ftpClient.login(user, password);
if (path.length()!=0) ftpClient.cd(path);
ftpClient.binary();
TelnetOutputStream os=ftpClient.put(filename);
File file_in=new File(filename);
FileInputStream is=new FileInputStream(file_in);
byte[] bytes=new byte[1024];
int c;
while ((c=is.read(bytes))!=-1){
os.write(bytes,0,c);}
is.close();
os.close();
ftpClient.closeServer();
} catch (IOException ex) {;}

//从FTP服务器上下传一个文件
String server="FTP服务器";
String user="登录名";
String password="登录密码";
String path="FTP路径";
String filename="要下传的文件";
try {
FtpClient ftpClient=new FtpClient();
ftpClient.openServer(server);
ftpClient.login(user, password);
if (path.length()!=0) ftpClient.cd(path);
ftpClient.binary();
TelnetInputStream is=ftpClient.get(filename);
File file_out=new File(filename);
FileOutputStream os=new
FileOutputStream(file_out);
byte[] bytes=new byte[1024];
int c;
while ((c=is.read(bytes))!=-1) {
os.write(bytes,0,c);
}
is.close();
os.close();
ftpClient.closeServer();
} catch (IOException ex) {;}
lantian1979 2003-10-22
  • 打赏
  • 举报
回复
谢了,我试试
clapton 2003-10-22
  • 打赏
  • 举报
回复
我这两天正好正在做上传,接着上面的一部分代码,按下面的方法可以实现上传,但是功能很不完善,我也很郁闷:(
........

File file = new File(filepathname);
RandomAccessFile sendFile = new RandomAccessFile(filepathname,
"r");
TelnetOutputStream outs = client.put(file.getName());

DataOutputStream outputs = new DataOutputStream(outs);
int ch;
while (sendFile.getFilePointer() < sendFile.length()) {
ch = sendFile.read();
outputs.write(ch);
}
outs.close();
sendFile.close();
System.out.println("success");
client.closeServer();

.....
clapton 2003-10-22
  • 打赏
  • 举报
回复
这里有一些讨论
http://forum.java.sun.com/thread.jsp?thread=217004&forum=54&message=752443

import sun.net.ftp.*;
String server = "ftp.fileplanet.com";
String user = "me";
String passwd = "1234";
FtpClient client = new FtpClient();
client.openServer(server);
client.login(user, passwd);
client.binary();//
client.cd("games");
////DO NOT CLOSE THIS INPUTSTREAM UNTIL YOU WANT TO CLOSE YOUr CONNECTION
TelnetInputStream in = client.get("pacman.exe");
//now do whatever u want with this inputstream
lantian1979 2003-10-22
  • 打赏
  • 举报
回复
还有人会吗?
lantian1979 2003-10-17
  • 打赏
  • 举报
回复
谢谢machozhao(Macho),我收到你的邮件了,也可以运行,但是我想要的是能嵌入到jsp中的简单的ftp(只实现上传下载固定的内容),无论如何谢谢了!:)
machozhao 2003-10-17
  • 打赏
  • 举报
回复
你试试SourceForge的jFTP
发给你了!

81,090

社区成员

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

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