I'm trying to get an image off the internet from an URL in java. I'm using the following code.
URL url = new URL(webAddress);
image = ImageIO.read(url);
Sometimes it works and sometimes it just hangs indefinitely, depending on what WebAddress is. No error message, it just keeps running and doing nothing.
There are definitely images at the addresses where it hangs forever, as confirmed by copying and pasting them into a web browser. There appears to be no pattern to which ones work and which ones don't- they're all jpegs. I've done some searching and found some other methods for getting an image from an URL, but the same thing happens with all of them- they work on some images and hang on others.
Do you have any idea what could be causing this, and how to fix it?