wood burning stoves 2.0*
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 Android Security Essentials Live Lessons this week in the Android 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: 38041
    
  22
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: 18541
    
    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: 394
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: List Files of Remote Directory
 
Similar Threads
how to check for the new file created in a directory
how to check for the new file created in a directory
How to list directory structure under a file server using java and jsp
Create a file object from avilable in a URL without downloading it
how to check for the new file created in a directory