[b]properties文件读取[/b]
public class PropertiesUtil {
private static final LoggerAdapter logger = LoggerAdapterFactory
.getLogger(MTPLogType.WEB);
/**
* 读取properties文件,返回Map
* @param resourceFileName
* @return
*/
public static Map<String, String> loadFile(String resourceFileName) {
Map<String, String> data = new HashMap<String, String>();
InputStream is = null;
try {
is = Thread.currentThread().getContextClassLoader()
.getResourceAsStream(resourceFileName);
Properties properties = new Properties();
properties.load(is);
for (Map.Entry<Object, Object> entry : properties.entrySet()) {
data.put((String) entry.getKey(), (String) entry.getValue());
}
return data;
} catch (Exception e) {
logger.error("load "+resourceFileName+" error", e);
return null;
} finally {
if (is != null) {
try {
is.close();
is = null;
} catch (IOException e) {
logger.error("", e);
}
}
}
}
}