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 目录

  • 相关阅读:
    7-11
    7-9
    7-8
    7-7
    7-6
    7-5
    7-4
    7-3
    第08次:升级《陋习手记》完善主从UI
    第07次:升级《陋习手记》显示多条数据
  • 原文地址:https://www.cnblogs.com/kwaitfort/p/9780830.html
Copyright © 2011-2022 走看看