Retrieving a remote directory listing |
Getting a directory listing as a String
To get a directory listing returned as a string you may use the Ftp#getDirListingAsString method.
Example
// get directory listing as a string String dirListing = ftp.getDirListingAsString();
Getting a directory listing as an Enumeration
In some cases you will want to evaluate the entries returned in a directory listing. In this case you will want to use the Ftp#getDirListing method. This method returns a java.util.Enumeration of FtpFile. Each FtpFile instance represents a read-only entry in the directory listing and may be queried for additional information.
Example
// get directory listing Enumeration listing = ftp.getDirListing();
// enumerate thru listing printing filename for each entry while(listing.hasMoreElements()) { FtpFile file = (FtpFile)listing.nextElement(); System.out.println("Filename: " + file.getFilename()); }
See also
|