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?
-
What have you done so far? Also what do you mean by "without downloading them"? To read any file, you *have* to download it. – Vivin Paliath Oct 07 '11 at 16:53
-
2I am guessing that the OP is okay with _downloading_ the contents of the files to do processing but does not want to end up with all the files on the local hard drive? Either way though, the same amount of traffic will be going over the wire... – Jesse Webb Oct 07 '11 at 17:05
-
2I think the question is how how to automate the process - the file should be loaded as temporary, opened, then optionaly removed. – Zon Jul 31 '13 at 10:24
2 Answers
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:

- 15,004
- 9
- 62
- 103
listFiles() for instance.
http://commons.apache.org/net/apidocs/org/apache/commons/net/ftp/FTPClient.html

- 241
- 2
- 3
-
1the listFiles() method pretty much like its FTP counter-part LIST, only gets you informations about files/directories, it does not help you in dowmloading the content or, you know, "getting it without downloading it" – Shivan Dragon Oct 07 '11 at 17:22