读取properties文件和属性
2013-04-26 18:16
337 查看
public class PropertiesUtils { /** * 配置文件. */ private Properties prop; /** * 输入流. */ private InputStream is; /** * 构造函数. * * @param filename * 以“/”开头,根据工程项目路径读取 */ public PropertiesUtils(String filename) { prop = new Properties(); is = getClass().getResourceAsStream(filename); try { prop.load(is); } catch (IOException e) { System.out.print(e.getMessage()); e.printStackTrace(); } finally { if (is != null) { try { is.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } } /** * 读取属性. * * @param propertyName * @return */ public String getProperties(String propertyName) { return prop.getProperty(propertyName); } }
相关文章推荐
- 读取资源属性文件(properties)java.util.ResourceBundle使用详解
- 读取Properties属性文件
- C# 读取Properties属性文件
- 【SQL】JDBC读取properties属性文件
- java 读取 properties 属性文件
- 警告:不能读取 AppletViewer 的属性文件: C:\Users\Administrator\.hotjava\properties
- Spring配置文件中读取properties文件的属性
- spring中属性文件properties的读取
- Spring中属性文件properties的读取与使用
- 注解形式读取properties文件中的属性
- springboot之读取properties属性文件
- Spring中属性文件properties的读取与使用
- Spring中属性文件properties的读取与使用
- java读取properties属性文件值方法
- java 读取属性文件 properties
- java读取Properties属性文件的方法
- Spring读取数据连接属性文件properties(单个和多个)
- java读取properties属性文件
- Java学习笔记——JDBC读取properties属性文件
- 读取.properties属性文件--今天的郁闷