简体   繁体   中英

Listing files from a remote URL using Java

I would like to list the files in a certain URL that requires authentication. Note that I have no access to the FTP server. Is there any possible way that I can do this using Java?

Accessing FTP from java is at best an arduous task, because the standard library doesn't provide anything for it. However, there are a few ways. There are three way to read directory listings, explained on nsftools :

  • Write your own class to talk to the FTP server. This is very compicated, and there are already such classes.
  • Use the sun.net.ftp.FTPClient class. This class is used internally by the java library to download files from FTP, but it is undocumented, not guaranteed to be present in all java implementations, &c. Plus, directory listings are very hard to parse.
  • Use the Jarkarta Net FTP library. This I think is the best option, but it has only one disadvantage: You need to supply the jar file as a dependency.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM