Well I'm not really sure what you mean by "download". In order to get something via FTP you must issue the FTP GET command which will open a stream towards your client and start sending the bytes of the requested file via that stream. Now most FTP clients gather up all those bytes and write them to a file on the local disk, but you can ofcourse make some Java code that does not do that last part, instead you may choose to write the bytes in memory, or parse them as they come in and discard some of them, etc.
And yes, I do realise that I'm not giving you to the point instructions on how to use Apache's commons net library to do that, because I believe that you should first understand the basics of what you're trying to do before you venture into using a library that makes an abstraction on top of it all.
发布评论
评论(2)
好吧,我不太确定“下载”是什么意思。为了通过 FTP 获取某些内容,您必须发出 FTP GET 命令,该命令将向您的客户端打开一个流,并开始通过该流发送所请求文件的字节。现在大多数 FTP 客户端都会收集所有这些字节并将它们写入本地磁盘上的文件,但是您当然可以编写一些不执行最后一部分的 Java 代码,而是可以选择将字节写入内存中,或者解析它们 是的,我确实意识到我并没有给你关于如何使用 Apache 的 commons net 库来做到这一点的重点说明,因为
我相信你应该首先了解您之前想要做的事情的基础知识冒险使用一个在这一切之上进行抽象的库。
查找基本 FTP 操作:
http://www.cs.colostate.edu/helpdocs/ 首先是ftp.html
和 Java I/O 基础知识:
http://download.oracle.com/javase/tutorial/essential/io/
Well I'm not really sure what you mean by "download". In order to get something via FTP you must issue the FTP GET command which will open a stream towards your client and start sending the bytes of the requested file via that stream. Now most FTP clients gather up all those bytes and write them to a file on the local disk, but you can ofcourse make some Java code that does not do that last part, instead you may choose to write the bytes in memory, or parse them as they come in and discard some of them, etc.
And yes, I do realise that I'm not giving you to the point instructions on how to use Apache's commons net library to do that, because I believe that you should first understand the basics of what you're trying to do before you venture into using a library that makes an abstraction on top of it all.
Look up the basic FTP operations:
http://www.cs.colostate.edu/helpdocs/ftp.html
and the basics of Java I/O first:
http://download.oracle.com/javase/tutorial/essential/io/
例如,listFiles()。
http://commons.apache.org/net /apidocs/org/apache/commons/net/ftp/FTPClient.html
listFiles() for instance.
http://commons.apache.org/net/apidocs/org/apache/commons/net/ftp/FTPClient.html