enterprisedt.com Forum Index CompleteFTP
RegisterSearchFAQMemberlistUsergroupsLog in
Reply to topic Page 1 of 1
Need to get a list of file ending with .txt
Author Message
Reply with quote
Post Need to get a list of file ending with .txt 
I am able to remotely login, and change directories. I am at the point where I need to get a list of just the files that end with .txt and I only want the names of those files in the array.

I am having a hard time understanding your manual. It looks like I could use listFiles() or getNames(), but there is no hint of how to use the commands to do this function.

The code I have at this point is:

// Get current directory listing
log.info("Getting current directory listing");
FTPFile[] files = ftp.directoryList(".");
for (int i = 0; i < files.length; i++) {
log.info(files[i].toString());
}

This code returns everything about all of the files in the directory.

View user's profile Send private message
Reply with quote
Post Re: Need to get a list of file ending with .txt 
The server may support ftp.directoryList("*.txt")

View user's profile Send private message Visit poster's website
Reply with quote
Post that helped 
I now get just the information about the .txt files. Thank you.
Is there any way to just get the file name and not the rest of the data?

View user's profile Send private message
Reply with quote
Post Re: that helped 
use directoryNameList

View user's profile Send private message Visit poster's website
Reply with quote
Post 2 issues occured 
Bruce -
I tried replacing directoryList with directoryNameList as you suggested and I have 2 issues.
1. When I try to save the changes I get "A sharing violation occurred while accessing..." how do stop what ever is going on so I can save my changes?
2. If I re-build, I get an error "cannot find symbol" and the output of the build is pointing to "directoryNameList"

View user's profile Send private message
Reply with quote
Post  
let's forget issue #1.
That is an issue with the editor I was using that just happened at the same time.
So back to directoryList and directoryNameList. Is this part of a new library or is it a seperate library?

View user's profile Send private message
Reply with quote
Post  
These are both methods on FileTransferClient, which is in the existing edtftpj.jar (although a relatively recent addition).

View user's profile Send private message Visit poster's website
Reply with quote
Post  
Sould I download another copy of the package?

View user's profile Send private message
Display posts from previous:
Reply to topic Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum