My question is as one can access the file names in a local directory using the above code. How can i do the same for a url location?? And yes i know it's not possible to access url using the above code. Is there any way to do the same for a url location. using java.net.* or something else. I did tried to find the way but didn't find one!!
There's no way to get a directory listing unless code on the remote machine wants to give you one. Some web servers are configured to give directory listings of certain directories; that would just be an HTML page containing the list of files, and you'd access it using the HttpURLConnection class.
Another possibility is a ftp:// URL. An ftp server will generally be happy to give you directory listings, if you issue the appropriate command. For these, your best best is a third-party FTP library. There's one in Apache's Jakarta Commons, I believe.
If the URL is for the file: protocol, then you could convert it to a java.io.File, then use those methods to list the directory.
If the URL is for the http: protocol, then there is no concept of directories of files, and you fundamentally cannot do what you think you want to do. You will have to step back and look at the higher-level requirement you are trying to fulfill.
If the URL is for some other protocol, you'd better tell us what it is.
Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
sorry for delayed response.. I can render page with http access only and I did solved the problem. I used the html page giving directory listing to get the list of the files and viz-a-viz using regular expression to render the file names.
If the URL is for the http: protocol, then there is no concept of directories of files, and you fundamentally cannot do what you think you want to do.
You can when the server is implementing WebDav, can't you?
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Our first order of business must be this tiny ad:
SKIP - a book about connecting industrious people with elderly land owners