首页 > 代码库 > java属性文件读取,属性修改
java属性文件读取,属性修改
/** * 属性文件读取 * @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属性文件读取,属性修改
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。