Beispiel #1
0
 public void download() {
   InputStream in = null;
   CloseableHttpResponse res = null;
   while (true) {
     try {
       Center center = p.next();
       File file = new File(path + "\\" + center.getX() + "_" + center.getY() + ".png");
       file.createNewFile();
       HttpGet get = new HttpGet(centerToURL(center));
       System.out.println(get.getURI().toString());
       res = client.execute(get);
       in = res.getEntity().getContent();
       BufferedImage image = ImageIO.read(in);
       WriteImage(image, file);
     } catch (Exception e) {
       e.printStackTrace();
       break;
     } finally {
       try {
         in.close();
         res.close();
       } catch (Exception e) {
         e.printStackTrace();
       }
     }
     try {
       savePictureInfo();
     } catch (Exception e) {
       e.printStackTrace();
     }
   }
 }