I am trying to get an image from the internet from a url in java. I am using the following code.
URL url = new URL(webAddress);
image = ImageIO.read(url);
Sometimes it works, and sometimes it just hangs endlessly, depending on what WebAddress is. There is no error message, it just works and does nothing.
At the addresses where it is hung, there are always images confirmed by copying and pasting them into a web browser. It seems that there are no templates with which they work, and which - not all - they are all jpeg. I did some searches and found some other ways to get the image from the url, but the same thing happens with all of them: they work with some images and hang on others.
Do you have any idea what could be causing this, and how to fix it?
source
share