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.
Have your server deploy a Servlet to retrieve a list of files from the folder specified by the request it receives. At your client end point, your application sends a request to the server by providing a path (virtual? relative ?) you intend to list. The servlet
will return the list of files in the requested path, retrieved from the server's OS. Then, it serializes the file list to the client end point for further processing.
If you can render the page with HTTP access only then:
Use the HTML page and parse it giving directory listing to get the list of the files and viz-a-viz using regular expression to render the file names.