How to read files from FTP without downloading them?

In my code for the index file, I need to access the FTP files and read them all without downloading them, how can I do this with the org.apache.commons.net library?

+1
java stream apache ftp
07 Oct 2018-11-11T00:
source share
2 answers

Well, I'm not quite sure what you mean by “download”. To receive something via FTP, you must issue an FTP GET command, which will open a stream to your client and begin sending bytes of the requested file through this stream. Now most FTP clients collect all these bytes and write them to a file on the local disk, but you can make Java code that does not execute this last part, instead you can write bytes in memory or parse them when they come in and discard some of them etc.

And yes, I understand that I am not giving you exact instructions on how to use the clean Apache commons library for this, because I believe that you must first understand the basics of what you are trying to do before you start using the library, which makes an abstraction on top of everything.

Check out basic FTP operations:

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

and the basics of Java I / O:

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

+3
07 Oct 2018-11-11T00:
source share
— -
+1
Oct 07 2018-11-17T00:
source share



All Articles