java资源文件操作类
来源:互联网 发布:万方数据库导出文献 编辑:程序博客网 时间:2024/05/21 17:50
import java.text.MessageFormat;
import java.util.ResourceBundle;
/**
* A tool used to get the parameters from resource files.
*
* @author lixq
* @version 1.0
*/
public class MessageBundle
{
/**
* Initializes ResourceBundle with resource file.
*/
private static ResourceBundle bundle = ResourceBundle
.getBundle("MUConfig");
private MessageBundle()
{
}
/**
* Get a message from the bundle.
*
* @param key The message key
* @return The message
*/
public static String get(final String key)
{
String message = null;
try
{
// Get the message
message = bundle.getString(key);
}
catch (RuntimeException e)
{
// If messasge was not found, return the key
message = key;
}
return message;
}
/**
* Get the message from MessageBundle
* and stuff an argument into the message.
*
* @param key The message key
* @param argument The arguments for the message
* @return The message
*/
public static String get(final String key, final String argument)
{
String message = MessageBundle.get(key);
return MessageFormat.format(message, new Object[] {argument});
}
/**
* Get the message from MessageBundle
* and stuff multiple arguments into the message.
*
* @param key The message key
* @param arguments The arguments for the message
* @return The message
*/
public static String get(final String key, final Object[] arguments)
{
String message = MessageBundle.get(key);
return MessageFormat.format(message, arguments);
}
}
import java.util.ResourceBundle;
/**
* A tool used to get the parameters from resource files.
*
* @author lixq
* @version 1.0
*/
public class MessageBundle
{
/**
* Initializes ResourceBundle with resource file.
*/
private static ResourceBundle bundle = ResourceBundle
.getBundle("MUConfig");
private MessageBundle()
{
}
/**
* Get a message from the bundle.
*
* @param key The message key
* @return The message
*/
public static String get(final String key)
{
String message = null;
try
{
// Get the message
message = bundle.getString(key);
}
catch (RuntimeException e)
{
// If messasge was not found, return the key
message = key;
}
return message;
}
/**
* Get the message from MessageBundle
* and stuff an argument into the message.
*
* @param key The message key
* @param argument The arguments for the message
* @return The message
*/
public static String get(final String key, final String argument)
{
String message = MessageBundle.get(key);
return MessageFormat.format(message, new Object[] {argument});
}
/**
* Get the message from MessageBundle
* and stuff multiple arguments into the message.
*
* @param key The message key
* @param arguments The arguments for the message
* @return The message
*/
public static String get(final String key, final Object[] arguments)
{
String message = MessageBundle.get(key);
return MessageFormat.format(message, arguments);
}
}
- java资源文件操作类
- Java资源文件的读写操作(Properties类)
- 操作资源文件
- Spring文件资源操作
- 资源文件操作总结
- 资源文件操作
- [Java工具类]Spring常用工具类 1.文件资源操作和Web相关工具类
- Android资源文件在配置文件中的使用与java代码对资源文件的操作
- java文件操作类
- Java文件操作类
- Java文件操作类
- java 文件类操作
- ASP.NET操作资源文件
- 安卓--操作资源文件
- c#:操作resx资源文件
- Java资源文件管理公共类
- java查找资源文件URL工具类
- R.java R文件(资源类)
- Directory Server 6 HA with Sun Cluster
- 《PetShop》系列之一 PetShop的系统架构设计
- mplayerplug-in
- 从flex application到web application
- Find a PID with ps + awk (更新中)
- java资源文件操作类
- flex 学习笔记
- Opensparc T1概述(硬件)
- 测试相关工具
- outlook2007 邮件正文出现乱码,如何解决?
- 金蝶称与IBM业务合作不受雷曼破产影响
- STL容器 erase的使用陷阱 (二)
- linux vi的使用
- Oracle10g中的回收站