简体   繁体   中英

Java - url timing out

I am trying to download images off website... it works great locally... but when the applet is run via web browser.. it gets cut off. For example, it downloads the images great but around 460-500... the image downloading suddenly stop.

Here's what I'm using:

                for (int i = 0; i < NUM_TILES; i++) {

                        try {
                System.out.println("Downloading tile " + i + " of "+NUM_TILES);
                File outputFileLocation = new File (System.getenv("APPDATA") + "\\.mystik\\tiles\\t"+i+".png");             
                String imgURL="line_tile/t"+i+".png";
                URL urlItem = new URL(imgURL);
                Image imageBR = ImageIO.read(urlItem);
                BufferedImage cpimg=(BufferedImage) imageBR;
                ImageIO.write(cpimg, "png", outputFileLocation);
                        } catch (MalformedURLException e1) {
                            e1.printStackTrace();
                        } catch (IOException ex) {
                            ex.printStackTrace();
                        }
                }
                System.out.println("Tiles downloaded!"); 

Why is it cutting off?

Why is it cutting off?

It is hard to say. Have you checked the Java console in the web browser? Are you getting an exception stacktrace?

One possibility is that the browser has decided that the applet has taken too long ... but I'm just guessing.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM