获得properties文件中某个key对应着的value

// 路径名称 + properties的名称,不要“properties”
private static final String BUNDLE_NAME = "com.xxx.cs.mm.service.messages"; private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME); public static String getString(String key) {
try {
return RESOURCE_BUNDLE.getString(key);
} catch (MissingResourceException e) {
return '!' + key + '!';
}
}

Format其中的值

MessageFormat.format(RESOURCE_BUNDLE.getString("SomeKey"), new Object[] { "1", "2" }));

java读取properties文件的内容的更多相关文章

  1. java分享第十六天( java读取properties文件的几种方法&java配置文件持久化:static块的作用)

     java读取properties文件的几种方法一.项目中经常会需要读取配置文件(properties文件),因此读取方法总结如下: 1.通过java.util.Properties读取Propert ...

  2. 用java读取properties文件--转

    今天为了通过java读取properties文件,google了很长时间,终于找到了.现在特记录之和大家一起分享.     下面直接贴出代码:java类 public class Mytest pub ...

  3. java 读取properties文件总结

    一.java读取properties文件总结 在java项目中,操作properties文件是经常要做的,因为很多的配置信息都会写在properties文件中,这里主要是总结使用getResource ...

  4. java基础学习总结——java读取properties文件总结

    摘录自:http://www.cnblogs.com/xdp-gacl/p/3640211.html 一.java读取properties文件总结 在java项目中,操作properties文件是经常 ...

  5. java读取properties文件时候要注意的地方

    java读取properties文件时,一定要注意properties里面后面出现的空格! 比如:filepath = /home/cps/ 我找了半天,系统一直提示,没有这个路径,可是确实是存在的, ...

  6. java基础—java读取properties文件

    一.java读取properties文件总结 在java项目中,操作properties文件是经常要做的,因为很多的配置信息都会写在properties文件中,这里主要是总结使用getResource ...

  7. Java基础学习总结(15)——java读取properties文件总结

    一.java读取properties文件总结 在java项目中,操作properties文件是经常要做的,因为很多的配置信息都会写在properties文件中,这里主要是总结使用getResource ...

  8. java读取properties文件总结

    一.java读取properties文件总结 在java项目中,操作properties文件是经常要做的,因为很多的配置信息都会写在properties文件中,这里主要是总结使用getResource ...

  9. Java读取properties文件连接数据库

    先说为什么要有这种东西,或者我们为什么要用这种方式来写,先看经常用的方法,我们经常写的 package util; import java.sql.Connection; import java.sq ...

随机推荐

  1. C# 网络通信基础 总结

    1.WebClient类 如果只是想从特定的URI(统一资源标识符)请求文件,则可以使用最简单的.NET类,System.Net.WebClient.支持http:.https:和file:标识符开头 ...

  2. 在Python中,令values=[0,1,2];values[1]=values,为何结果是[0,[...],2]?

    转载自:http://www.zhihu.com/question/21000872/answer/16856382>>> values = [0, 1, 2] >>&g ...

  3. 230. Kth Smallest Element in a BST

    Given a binary search tree, write a function kthSmallest to find the kth smallest element in it. Not ...

  4. poj 2955 括号匹配 区间dp

    Brackets Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 6033   Accepted: 3220 Descript ...

  5. ZOJ 1045 HangOver

    原题链接 题目大意:叠扑克牌,给出伸出长度,问最多需要几张扑克牌. 解法:循环累加.退出循环后向上取整输出. 参考代码: #include<iostream> using namespac ...

  6. ubuntu 以root 运行程序

    body{ font-family: "Microsoft YaHei UI","Microsoft YaHei",SimSun,"Segoe UI& ...

  7. 第一课 T语言关键字(版本TC5.0)

    关键字 TC综合开发工具的语法里包含了大量的关键字,而且对TC综合开发工具支持的关键字都做了亮色处理,以便大家在写脚本的时候容易区分. 关键字在使用的时候,都有特定的作用,不能作为变量名.函数名等等使 ...

  8. makefile--模式规则(七)

    原创博文,转载请标明出处--周学伟http://www.cnblogs.com/zxouxuewei/ 上一节讲到目录创建成功,目标文件没有生产到对应目录下,这里我们先给目标文件加上对应目录,这样的话 ...

  9. leetcode 112 Path Sum ----- java

    Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all ...

  10. leetcode 92 Reverse Linked List II ----- java

    Reverse a linked list from position m to n. Do it in-place and in one-pass. For example:Given 1-> ...