Beispiel #1
0
  /** Met dans le cache le résultat de l'url indiquée */
  public boolean putInCache(String url) throws Exception {

    // Lecture
    MyInputStream in = null;
    try {
      in = Util.openStream(url);
      byte buf[] = in.readFully();

      // Nettoyage et Ecriture
      String id = codage(url);
      File g = new File(dir + Util.FS + id);
      g.delete();
      RandomAccessFile f = null;
      try {
        f = new RandomAccessFile(dir + Util.FS + id, "rw");
        f.write(buf);
      } finally {
        if (f != null) f.close();
      }
      aladin.trace(3, "Put in cache [" + url + "]");
      return true;
    } catch (Exception e) {
      if (aladin.levelTrace >= 3) e.printStackTrace();
    } finally {
      if (in != null) in.close();
    }

    return false;
  }
Beispiel #2
0
 private boolean getIsColorByPath(String path, boolean local) {
   String ext = inPNG ? ".png" : ".jpg";
   MyInputStream in = null;
   try {
     if (local) return Util.isJPEGColored(path + Util.FS + "Norder3" + Util.FS + "Allsky" + ext);
     in = new MyInputStream(Util.openStream(path + "/Norder3/Allsky" + ext));
     byte[] buf = in.readFully();
     return Util.isColoredImage(buf);
   } catch (Exception e) {
     aladin.trace(3, "Allsky" + ext + " not found => assume B&W survey");
     return false;
   } finally {
     try {
       if (in != null) in.close();
     } catch (Exception e1) {
     }
   }
 }