Properties 转换成Map

来源:互联网 发布:变脸软件 编辑:程序博客网 时间:2024/05/03 06:43
public class OrderService {    private static Logger logger = Logger.getLogger(OrderService.class);    private static Properties props = null;    static {        props = new Properties();        try {            InputStream in = OrderService.class.getClass().getResourceAsStream("/status.properties");            props.load(in);        } catch (Exception e) {            logger.error("状态资源文件未加载" + e.getMessage());        }    }    public static void main(String[] args) {        Map<String, String> map = new HashMap<String, String>((Map) props);        Set propertySet = map.entrySet();        for (Object o : propertySet) {            Map.Entry entry = (Map.Entry) o;            System.out.printf("%s = %s%n", entry.getKey(), entry.getValue());        }    }}
status.base.order10 = CLOSE_REFUNDstatus.base.order7 = PAID_UNSENTstatus.base.order8 = PAID_TO_CONFIRM
0 0
原创粉丝点击