aspose file tools*
The moose likes Java in General and the fly likes List Files of Remote Directory Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "List Files of Remote Directory" Watch "List Files of Remote Directory" New topic
Author

List Files of Remote Directory

Vivek Sam
Greenhorn

Joined: Jul 29, 2004
Posts: 8
Hi ,

I have a requirement to dynamically select a file from a remote location based on the regular expression.

Now i used to list the files , this fails as it says that the parameter directory is not a directory.

Now i understand that the it is looking on the local system for the directory , Can anybody tell me as to how can I connect to the remote machine and list the files at that location

If it is a complex task , can anybody please suggest a simple way to search for a file present on the remote location using regex.

Thanks
Vivek
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39393
    
  28
Certainly too difficult for us on "beginning". Maybe the "in General" people will be able to cope
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18651
    
    8

We don't know anything about the network which includes your computer and this remote directory, so we can only guess.

Okay. My guess is that maybe you can map a drive to this remote directory before you run the code.
H Paul
Ranch Hand

Joined: Jul 26, 2011
Posts: 471
    
    4
I take this as an opportunity to learn new way of doing this.

Without any technical environment/constraint, here is my guess:

My guess: May or not work

Use FTPClient

FTPFile[] listFiles(String pathname, FTPFileFilter filter)
Version of listFiles(String) which allows a filter to be provided.

And implement FTPFileFilter
Vivek Sam
Greenhorn

Joined: Jul 29, 2004
Posts: 8
Hi All,

Resolved the issue by using JSch , basically a SFTP connection to the Remote machine.

Please refer the below links for example and the home page of the same.

JSch Home Page

JSch SFTP Example

Thanks to all for their replies.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: List Files of Remote Directory