
com.kukababy.utils.PropUtil Maven / Gradle / Ivy
package com.kukababy.utils;
import java.util.Locale;
import java.util.Properties;
import java.util.ResourceBundle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @describe 描述
* @author 老汪 [email protected]
* @date 创建时间:2015年4月22日 下午4:15:03
*
*/
public class PropUtil {
private static final Logger log = LoggerFactory.getLogger(PropUtil.class);
private static ResourceBundle bundle;
public static String get(String code) {
initBundle();
if(!bundle.containsKey(code)){
return null;
}
return bundle.getString(code);
}
public static String get(String code,String df) {
initBundle();
if(!bundle.containsKey(code)){
return df;
}
return bundle.getString(code);
}
private static void initBundle() {
if (bundle == null) {
bundle = ResourceBundle.getBundle("config", Locale.getDefault());
}
}
public static void main(String args[]) {
System.out.println(get("sc-api.userName"));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy