[java]PropertiesUtils操作属性文件

来源:互联网 发布:淘宝商品名称字数限制 编辑:程序博客网 时间:2024/06/04 23:31
public class PropertiesUtils {    private static Properties properties = null;    static {        if(null == properties){            properties = new Properties();            InputStreamReader reader = null;            try{                reader = new InputStreamReader(PropertiesUtils.class.getClassLoader().getResourceAsStream("resources.properties"),"utf-8");                properties.load(reader);                reader.close();            }catch (Exception e){                e.printStackTrace();            }finally {                if(reader != null){                    reader = null;                }            }        }    }    private PropertiesUtils(){}    public static String getString(String key){        return properties.getProperty(key);    }}
0 0