propertiesmanager.java

来自「用J2EE开发的网站,可以应用到图书馆,图书超市」· Java 代码 · 共 51 行

JAVA
51
字号
package ksnb;

import java.io.FileNotFoundException;
import java.util.Hashtable;
import java.util.Properties;

public class PropertiesManager {
  private static Hashtable propertiesCache;
  private static java.lang.Object loaderLock;
  static {
                loaderLock = new Object();
        }

  /**
   * PropertiesManager Constructor
   */
  public PropertiesManager() {
    super();
  }

  /**
   * Acquire one configuration information
   * Create timestamp(2003-09-30 11:00:10)
   * @return java.util.Properties
   * @param propertiesFileName java.lang.String
   */
  public static java.util.Properties getProperties(String propertiesFileName)
                  throws java.io.FileNotFoundException {
    if (propertiesCache == null || propertiesCache.get(propertiesFileName) == null)
      synchronized (loaderLock) {

        if (propertiesCache == null
            || propertiesCache.get(propertiesFileName) == null) {
          propertiesCache = new Hashtable();
          propertiesCache.put(
                propertiesFileName,
                new PropertiesLoader().getProperties(propertiesFileName));
        }
      }
    return (Properties) propertiesCache.get(propertiesFileName);
  }

  /**
   * Initialize information
   * Create timestamp(2003-09-30 11:03:32)
   */
  public static void reset() {
    propertiesCache = null;
  }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?