Ejemplo n.º 1
0
  private final void clearDataCache() {
    java.util.Iterator it = dataCache.values().iterator();

    while (it.hasNext()) {
      File f = (File) it.next();
      f.delete();
    }
  }
Ejemplo n.º 2
0
  private final synchronized File getDataCacheFile(byte[] data) {
    try {
      java.security.MessageDigest digest = java.security.MessageDigest.getInstance("MD5");
      digest.update(data);

      String key = bytesToHex(digest.digest());

      if (dataCache.containsKey(key)) return (File) dataCache.get(key);

      File f = new File(this.getCacheDir(), "bindata_" + key);
      f.delete();
      FileOutputStream os = new FileOutputStream(f);
      os.write(data, 0, data.length);
      dataCache.put(key, f);
      return f;
    } catch (Throwable e) {
    }

    return null;
  }