views:

67

answers:

1

HI...

Currently I m working in a application in which application allows to access directory (which contains some files) from file server to Application (client).

I tried following code..

URL url=("http://192.168.5.555/file-server/user/images/");
URI uri=url.toURI();
File list[];

list= new File(uri).listFiles();

But its thrown java.lang.IllegalArgumentException Exception.

I don't know how this happen?

I simply access images directory from the given URL (file server).

Help me...

+1  A: 

That isn't going to work. The java.io.File operates on the local disk file system only, i.e. on URI's starting with file:// only. It would otherwise indeed going to be too easy to leech files from places where you aren't allowed to do so.

Check if the server in question supports FTP, then you can just use FTPClient#listFiles() for this. If it doesn't, but it supports directory listing, then you need to parse the HTML response containing the directory listing with a HTML parser like Jsoup and then refire a new request on every found link.

If it doesn't support FTP or directory listing, then you're lost and you're probably trying to do bad things.

BalusC