简体   繁体   English

Java-网址超时

[英]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. 我正在尝试从网站上下载图像...在本地效果很好...但是当applet通过网络浏览器运行时..它被切断了。 For example, it downloads the images great but around 460-500... the image downloading suddenly stop. 例如,它下载的图像很棒,但是大约为460-500。。。图像下载突然停止。

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? 您是否已在网络浏览器中检查了Java控制台? Are you getting an exception stacktrace? 您是否获得异常stacktrace?

One possibility is that the browser has decided that the applet has taken too long ... but I'm just guessing. 一种可能是浏览器认为applet花费的时间太长了……但是我只是在猜测。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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