package com.helper; import java.io.IOException; import java.io.InputStream; import java.util.Properties; /** * 读取文件/onload.properties类 * * @author pengbei * */ public final class Env extends Properties { /** * */ private static final long serialVersionUID = 1L; // private static Env env; private static String properties = "/onload.properties"; public static Env getEnv() { return getEnv(properties); } public static Env getEnv(String propertie) { properties = propertie; // if (env == null) { // makeInstanse(); // } Env env = new Env(); return env; } // private static synchronized void makeInstanse() { // if (env == null) { // env = new Env(); // } // } private Env() { InputStream iStream; iStream =Thread.currentThread().getContextClassLoader().getResourceAsStream(properties); if (iStream == null) { System.out.println("读取" + properties + "文件异常!"); } else { try { load(iStream); } catch (IOException e) { e.printStackTrace(); } } properties = "/onload.properties";// 还原文件属性 } }