I want to create a small program in which the user will provide me with the url and then he/she will get the images present in that webpage. Below is the code from which I have started:
URL postURL = new URL(url);
InputStream inputStream = postURL.openStream();
BufferedReader br = new BufferedReader(new InputStreamReader(
inputStream));
String line;
StringBuilder sb = new StringBuilder("");
while ((line = br.readLine()) != null) {
sb.append(line);
}
loggerService.log(sb.toString());
return null;
It will provide me with the html of the webpage and search for the <img>
tags. But what if the url provided to me is something like Direct Image Link which contains the direct image, as it will not contain html. How to tackle this? Also, I'm eager to find out some apis that I could use.
Thanks in advance.