java属性文件读取,属性修改
2014-12-08 13:52
309 查看
/** * 属性文件读取 * @author bestmata * */ public class CommUtil { private static Logger logger=Logger.getLogger(CommUtil.class); private Properties getAttionReplyPro(){ try { InputStream in=CommUtil.class.getResourceAsStream("attionReply.properties"); Properties p=new Properties(); p.load(in); in.close(); return p; } catch (Exception e) { logger.error(e); } return null; } //获取关注的标示 public String getAttionFlag(){ Properties p=getAttionReplyPro(); String attionFlag=p.getProperty("attionFlag"); return attionFlag; } //设置attionFlag的值 public void setAttionFlag(String flag){ try { Properties p=getAttionReplyPro(); p.setProperty("attionFlag", flag); OutputStream out=new FileOutputStream(new File(CommUtil.class.getResource("attionReply.properties").toURI())); p.store(out, ""); out.flush(); out.close(); } catch (Exception e) { logger.error(e); } } public static void main(String[] args) { CommUtil a=new CommUtil(); a.setAttionFlag("fag4"); System.out.println(a.getAttionFlag()); } }
相关文章推荐
- java读取和修改Properties属性文件的value值
- 用java程序读取js文件并修改属性的值(用json-lib读写js文件)
- java 读取 property 属性文件的代码
- java中属性文件读取的例子
- Java 读取属性文件
- Java读取属性Properties文件的方法
- Java读取属性Properties文件的方法
- java实现读取flash的swf文件属性 - zhangjianwxh的专栏 - CSDNBlog
- 几种读取属性文件的JAVA实现方式(2005年)
- java中读取属性文件
- java读取properties属性文件值方法
- java读取本地属性文件
- java实现读取flash的swf文件属性
- JAVA读取文件的创建时间和修改时间
- java读取和修改ini配置文件
- 几种读取属性文件的JAVA实现方式
- JAVA读取属性文件来连接数据库
- java web 利用 commons-fileupload-1.2 实现文件上传 解决 中文乱码& 非文件属性的读取
- java读取properties属性文件值方法
- Java里读取属性文件例子