/**
* 属性文件读取
* @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属性文件读取,属性修改的更多相关文章

  1. SpringBoot入门 (二) 属性文件读取

    在上一篇中介绍了在idea中创建springboot工程及使用web工程输出“helloworld”到前端页面,本文学习在springboot工程中读取属性文件中的属性值. 一 自定义属性 在appl ...

  2. Spring MVC 属性文件读取注入到静态字段

    目录(?)[-] servlet-contextxml configproperties 示例属性 ConfigInfo 对应的配置bean 使用   在项目中,有些参数需要配置到属性文件xxx.pr ...

  3. 8、Spring+Struts2+MyBaits(Spring注解+jdbc属性文件+log4j属性文件)

    一.注解理论 使用注解来构造IoC容器 用注解来向Spring容器注册Bean.需要在applicationContext.xml中注册<context:component-scan base- ...

  4. 配置文件——App.config文件读取和修改

    作为普通的xml文件读取的话,首先就要知道怎么寻找文件的路径.我们知道一般配置文件就在跟可执行exe文件在同一目录下,且仅仅在名称后面添加了一个.config 因此,可以用Application.Ex ...

  5. javascript 理解对象--- 定义多个属性和读取属性的特性

    一 定义多个属性 ECMAScript5 定义了一个Object.defineProperties()方法,用于定义多个属性.此方法接受两个对象参数: 第一个对象:要添加或修改其属性的对象 第二个对象 ...

  6. java获得文件的最后修改时间

    原文:http://www.open-open.com/code/view/1453190044980 java的File类的lastModified()方法可以返回文件的最后修改时间: String ...

  7. Java 添加、读取、修改、删除Word文档属性

    Word文档属性包括常规.摘要.统计.内容.自定义等,其中摘要包括标题.主题.作者.经理.单位.类别.关键词.备注等项目,通过设置这些摘要信息或自定义属性可方便对文档的管理.本文中将主要介绍对文档摘要 ...

  8. SpringBoot 使用 @Value 从 YAML文件读取属性(转)

    在 YAML中有如下配置 paypal: mode:live 在类中,通过 @Value属性读取 @Value("${paypal.mode}") private String m ...

  9. SpringBoot 使用 @Value 从 YAML文件读取属性

    在 YAML中有如下配置 paypal: mode:live 在类中,通过 @Value属性读取 @Value("${paypal.mode}") private String m ...

随机推荐

  1. Android 调用图库选择图片实现和参数详解

    //选择图片,调用图库        bt4.setOnClickListener(new OnClickListener() { @Override            public void o ...

  2. Android写入文件操作权限

    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses- ...

  3. POJ-1488(字符串应用)

    Description TEX is a typesetting language developed by Donald Knuth. It takes source text together w ...

  4. HBase 事务和并发控制机制原理

    作为一款优秀的非内存数据库,HBase和传统数据库一样提供了事务的概念,只是HBase的事务是行级事务,可以保证行级数据的原子性.一致性.隔离性以及持久性,即通常所说的ACID特性.为了实现事务特性, ...

  5. JavaScript 随机数函数

    Math.random()*(m-n)+n random函数语法 Math.random();   random函数返回值 返回0和1之间的伪随机数,可能为0,但总是小于1,[0,1) 返回10-20 ...

  6. Apache HttpComponents Client 4.0快速入门/升级-2.POST方法访问网页

    Apache HttpComponents Client 4.0已经发布多时,httpclient项目从commons子项目挪到了HttpComponents子项目下,httpclient3.1和 h ...

  7. Intel 被 ARM 逼急了

    英特尔最近推出基于Silvermont架构Bay Trail系列处理器,相对前一代Bonnell架构的最突出的改进就是支持乱序执行 silvermon架构的处理器将出现在pc,平板等: List of ...

  8. Nested Class Templates

      Templates can be defined within classes or class templates, in which case they are referred to as ...

  9. Facebook登录 AndroidStudio

    简介 主页:https://www.facebook.com/ Android开发者支持:https://developers.facebook.com/docs/android/  应用管理:htt ...

  10. WPF DataGrid 之数据绑定

    1. Auto generation of columns 最简单的方法莫过于让DataGrid根据数据源中的字段自动生成列了: 根据实体类的公共属性, 能够自动生成四种类型的数据列,对应关系如下: ...