zoukankan      html  css  js  c++  java
  • 读取Properties文件简易代码

    public class Utils {
        private static Properties props = new Properties();
        
        static {
            ClassLoader classLoader = Utils.class.getClassLoader();
            InputStream inputStream = classLoader.getResourceAsStream("mapping.properties");
            try {
                props.load(inputStream);
            } catch (IOException e1) {
                e1.printStackTrace();
            }
        }
        
        public static String GetString(String key){
            String value = null;
            value = props.getProperty(key);
            return value;
        }
        
    }

    简易读取properties文件代码,其中properties文件放置在src/main/resources目录下

  • 相关阅读:
    605
    603
    509
    7-5
    6-5
    5-6
    5-3
    5-4
    5-5
    4-12
  • 原文地址:https://www.cnblogs.com/atomicbomb/p/6610977.html
Copyright © 2011-2022 走看看