如何在不下载的情况下从 FTP 读取文件? [英] How to read files from FTP without download them?

查看:41
本文介绍了如何在不下载的情况下从 FTP 读取文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的索引文件程序代码中,我需要访问 FTP 文件并阅读所有文件而不下载它们,我如何使用 org.apache.commons.net 库来做到这一点?

In my index file program code i need to access to FTP files and read all of them without download them,how can i do that with org.apache.commons.net library?

推荐答案

我不太清楚你所说的下载"是什么意思.为了通过 FTP 获取某些内容,您必须发出 FTP GET 命令,该命令将打开一个流向您的客户端并开始通过该流发送请求文件的字节.现在大多数 FTP 客户端收集所有这些字节并将它们写入本地磁盘上的文件,但是您当然可以编写一些不执行最后一部分的 Java 代码,相反您可以选择将字节写入内存或解析它们当他们进来并丢弃其中的一些,等等.

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.

是的,我确实意识到我并没有向您提供有关如何使用 Apache 的公共网络库来做到这一点的重点说明,因为我认为您应该首先了解您正在尝试做的事情的基础知识在你冒险使用一个在这一切之上进行抽象的库之前.

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.

查看基本的 FTP 操作:

Look up the basic FTP operations:

http://www.cs.colostate.edu/helpdocs/ftp.html

首先是 Java I/O 的基础知识:

and the basics of Java I/O first:

http://download.oracle.com/javase/tutorial/essential/io/

这篇关于如何在不下载的情况下从 FTP 读取文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆