up 有分,不然版主说我倒分,大家来up嘛
解决方案 »
- 如何用java实现snmp网络监控协议
- 大家帮忙看看这问题怎么解决!
- 推荐个网站——视频教程网
- 在axis2服务器端怎么才能像客户端那样调用axis2服务器端
- <BEA-101083> <Connection failure. java.net.SocketException: 管道断开 (errno:32)
- 用java实现给指定的QQ发信息
- Statement的一个很怪很怪的问题,请高手过来看看~
- 新手~~求大神帮忙xml转json
- 【500分】求“用jbuilder9 + weblogic开发web service的step by step教程?最好是调用ejb”急!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- .ear文件 用Weblogic Builder 部署时报错!!!怎么办???
- 奇怪的问题,resin怎么不能查错了
- tomcat能否记录下访问者的IP?
我只会java的
Properties theProps = new Properties();
String fileName = "xxxxx.properties";
InputStream is = getClass().getResourceAsStream(fileName);if (is!=null){
theProps.load(is);
out.println(theProps.getProperty("key"));
}
Usage Information
Here are some examples of usage: Object[] arguments = {
new Integer(7),
new Date(System.currentTimeMillis()),
"a disturbance in the Force"
}; String result = MessageFormat.format(
"At {1,time} on {1,date}, there was {2} on planet {0,number,integer}.",
arguments); output: At 12:30 PM on Jul 3, 2053, there was a disturbance
in the Force on planet 7. Typically, the message format will come from resources, and the arguments will be dynamically set at runtime.
Example 2: Object[] testArgs = {new Long(3), "MyDisk"}; MessageFormat form = new MessageFormat(
"The disk \"{1}\" contains {0} file(s)."); System.out.println(form.format(testArgs)); // output, with different testArgs
output: The disk "MyDisk" contains 0 file(s).
output: The disk "MyDisk" contains 1 file(s).
output: The disk "MyDisk" contains 1,273 file(s).
For more sophisticated patterns, you can use a ChoiceFormat to get output such as: MessageFormat form = new MessageFormat("The disk \"{1}\" contains {0}.");
double[] filelimits = {0,1,2};
String[] filepart = {"no files","one file","{0,number} files"};
ChoiceFormat fileform = new ChoiceFormat(filelimits, filepart);
form.setFormatByArgumentIndex(0, fileform); Object[] testArgs = {new Long(12373), "MyDisk"}; System.out.println(form.format(testArgs)); // output, with different testArgs
output: The disk "MyDisk" contains no files.
output: The disk "MyDisk" contains one file.
output: The disk "MyDisk" contains 1,273 files.
You can either do this programmatically, as in the above example, or by using a pattern (see ChoiceFormat for more information) as in:
form.applyPattern(
"There {0,choice,0#are no files|1#is one file|1<are {0,number,integer} files}.");
Note: As we see above, the string produced by a ChoiceFormat in MessageFormat is treated specially; occurances of '{' are used to indicated subformats, and cause recursion. If you create both a MessageFormat and ChoiceFormat programmatically (instead of using the string patterns), then be careful not to produce a format that recurses on itself, which will cause an infinite loop. When a single argument is parsed more than once in the string, the last match will be the final result of the parsing. For example, MessageFormat mf = new MessageFormat("{0,number,#.##}, {0,number,#.#}");
Object[] objs = {new Double(3.1415)};
String result = mf.format( objs );
// result now equals "3.14, 3.1"
objs = null;
objs = mf.parse(result, new ParsePosition(0));
// objs now equals {new Double(3.1)}
Likewise, parsing with a MessageFormat object using patterns containing multiple occurances of the same argument would return the last match. For example, MessageFormat mf = new MessageFormat("{0}, {0}, {0}");
String forParsing = "x, y, z";
Object[] objs = mf.parse(forParsing, new ParsePosition(0));
// result now equals {new String("z")}