I want to list every file with extension of ".png" under some url for example
"http://kgs:8080/KGS/assets/"
I want to retrieve the name of the file such as
background.png
foreground.png
How can i do this java?
Thank you
The HTTP protocol does not have a method for listing files in a directory, so this can't be done in the general case.
If a request made to http://kgs:8080/KGS/assets/ returns the directory listing in HTML, like some web servers do, you can parse that listing to obtain a list of URLs. Then you go over each URL and check if they end with .png.
If the content (the files) is not accessible from the html pages, it is impossible to get it without brute-forcing and guessing the paths. If the files are linked from the html pages, you may want to use some crawler for it.
http://kgs:8080/KGS/assets/returns a list, then you can parse that. Othwise there is no way to do this.