zoukankan      html  css  js  c++  java
  • 读取properties文件

      读取 配置文件的两个方法

    1.  xxx.class.getClassLoader() .getResourceAsStream(xxxx) 

    Properties p  =new Properties();
            p.load(Test.class.getClassLoader()
                    .getResourceAsStream
                    ("com/springFactory/spring.properties"));;
            // properties文件放在了  src 目录  
            // 编译后,properties 文件会在 bin目录(即classpath)
            
            String  vehicleTypeName  = p.getProperty("VehicleType");
            System.out.println(vehicleTypeName);

     

    2. 

    InputStream in = Thread.currentThread().

    getContextClassLoader().
    getResourceAsStream("jdbc.properties");
    p.load(in);

     

     3.  放在  resources 目录

  • 相关阅读:
    spring
    ajax
    jquary
    Java web 部分
    长跑马拉松
    面试的标准
    数据预处理——剔除异常值,平滑,归一化
    概率分布
    养生
    平滑的作用
  • 原文地址:https://www.cnblogs.com/kwaitfort/p/9780830.html
Copyright © 2011-2022 走看看