File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes ImageIO.read() timeout? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "ImageIO.read() timeout?" Watch "ImageIO.read() timeout?" New topic
Author

ImageIO.read() timeout?

Brendan Griffin
Greenhorn

Joined: Nov 04, 2010
Posts: 3
I'm using ImageIO to read an image from a URL as follows:


However I am finding on some occasions this hangs and never times out or throws a error but doesnt complete so it is hanging my program.
Is there any way to set it to timeout after a certain length of time?

I have checked the urls that i am using through a web browser and they do exist but can be slow to display the picture.

Thanks!
Kiaamaa Liammes
Ranch Hand

Joined: Oct 03, 2009
Posts: 32

Can you specify the Java version you are using , Java 1.6 has a more efficient image I/O


SCJP ,SCWCD
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39773
    
  28
And welcome to JavaRanch
Brendan Griffin
Greenhorn

Joined: Nov 04, 2010
Posts: 3
Kiaamaa Liammes wrote:Can you specify the Java version you are using , Java 1.6 has a more efficient image I/O


Java 1.5. Cant use 1.6 for this program unfortunately. Is there another mechanism that I can use that will give more control over timeouts?

Seeing as i'm asking about ImageIO...I am unsing it to get the image from a url. I then convert it to a byte[] to store in a db blob. Am i doing it correctly?
Kiaamaa Liammes
Ranch Hand

Joined: Oct 03, 2009
Posts: 32

i found a similar bug in JDK JDK Bug
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10519
    
    9

You might want to check out MediaTracker


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Brendan Griffin
Greenhorn

Joined: Nov 04, 2010
Posts: 3
Maneesh Godbole wrote:You might want to check out MediaTracker


that looks like a much messier way..would have to implement it in a class that extends a java.awt.Component and then have to go in to complex Image to BufferedImage conversion. might have to though...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ImageIO.read() timeout?