1 // Copyright 2000-2006 the Contributors, as shown in the revision logs.
2 // Licensed under the Apache Public Source License 2.0 ("the License").
3 // You may not use this file except in compliance with the License.
10 import java.util.zip.*;
11 import org.ibex.util.*;
13 public class PropertiesFile {
15 public static final int INTERVAL = 2000; /* ms */
18 private long lastChecked = 0;
19 private long lastModified = 0;
20 private Properties props = null;
22 public PropertiesFile(File f) throws IOException {
24 if (!f.exists()) throw new IOException("file " + f + " does not exist");
28 public String get(String key) {
30 return (String)props.get(key);
33 public void checkReload() {
34 long diff = System.currentTimeMillis() - lastChecked;
35 if (diff < INTERVAL) return;
38 if (lastModified == f.lastModified()) return;
39 lastModified = f.lastModified();
40 Properties newProps = new Properties();
41 newProps.load(new FileInputStream(f));
43 } catch (Exception e) { Log.warn(this, e); }