Reputation: 267
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
Upvotes: 0
Views: 89
Reputation: 12847
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.
Upvotes: 1
Reputation: 111369
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
.
Upvotes: 2