0

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

1
  • If the http://kgs:8080/KGS/assets/ returns a list, then you can parse that. Othwise there is no way to do this. Commented Jun 26, 2013 at 12:48

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you for your quick response Joni
1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.