Discuss edtFTPj (FTP) and edtFTPj/PRO (SFTP, FTPS and SCP), our Java file transfer clients.
no avatar
User

jcarrott

Posts

6

Joined

Sat May 02, 2009 6:32 am

Need to get a list of file ending with .txt

by jcarrott » Wed May 06, 2009 7:46 am

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.
no avatar
User

support2

Posts

3845

Joined

Tue May 18, 2004 8:30 am

Re: Need to get a list of file ending with .txt

by support2 » Wed May 06, 2009 8:08 am

The server may support ftp.directoryList("*.txt")
no avatar
User

jcarrott

Posts

6

Joined

Sat May 02, 2009 6:32 am

that helped

by jcarrott » Wed May 06, 2009 8:15 am

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?
no avatar
User

support2

Posts

3845

Joined

Tue May 18, 2004 8:30 am

Re: that helped

by support2 » Wed May 06, 2009 8:59 am

use directoryNameList
no avatar
User

jcarrott

Posts

6

Joined

Sat May 02, 2009 6:32 am

2 issues occured

by jcarrott » Thu May 07, 2009 3:46 am

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"
no avatar
User

jcarrott

Posts

6

Joined

Sat May 02, 2009 6:32 am

by jcarrott » Thu May 07, 2009 7:40 am

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?
no avatar
User

support2

Posts

3845

Joined

Tue May 18, 2004 8:30 am

by support2 » Thu May 07, 2009 9:17 pm

These are both methods on FileTransferClient, which is in the existing edtftpj.jar (although a relatively recent addition).
no avatar
User

jcarrott

Posts

6

Joined

Sat May 02, 2009 6:32 am

by jcarrott » Thu May 07, 2009 11:44 pm

Sould I download another copy of the package?

Who is online

Users browsing this forum: No registered users and 0 guests

Powered by phpBB ® | phpBB3 Style by KomiDesign
cron