zoukankan      html  css  js  c++  java
  • getResourceAsStream properties

     try (InputStream is = getClass().getResourceAsStream("/test.properties")) {
          Properties properties = new Properties();
          properties.load(is);
          ps=new PropertiesPropertySource("main", properties);
        } catch (IOException e) {
          log.error("Something went wrong", e);
        }
     private String getPomPerpertiesPath() {
        String classPath = getClass().getClassLoader().getResource("").getPath();
        String aString = "classes/";
        String targetPath = classPath.substring(0, classPath.lastIndexOf(aString));
        StringBuilder sb = new StringBuilder();
        sb.append(targetPath).append("maven-archiver/pom.properties");
        return sb.toString();
      }*/
      private Properties getProperties(InputStream is) throws IOException {
        Properties properties = new Properties();
        properties.load(is);
        log.info("All defined properties: {}", properties);
        return properties;
      }
      private Properties getProperties(String fileName) throws IOException {
        try (InputStream is = new FileInputStream(new File(fileName))) {
          Properties properties = new Properties();
          properties.load(is);
          log.info("All defined properties: {}", properties);
          return properties;
        }
     System.out.println(getClass().getClassLoader().getResource(""));
     System.out.println(getClass().getClassLoader().getResource("").getPath());
     System.out.println(getClass().getResource(""));
     System.out.println(getClass().getResource("").getPath());
    
    file:/C:/Users/lt32806/git/tempest/tempest-app/tempest-app-report/target/classes/
    /C:/Users/lt32806/git/tempest/tempest-app/tempest-app-report/target/classes/
    file:/C:/Users/lt32806/git/tempest/tempest-app/tempest-app-report/target/classes/com/citi/simpliciti/tempest/report/
    /C:/Users/lt32806/git/tempest/tempest-app/tempest-app-report/target/classes/com/citi/simpliciti/tempest/report/

    https://blog.csdn.net/wws921104/article/details/72637050/
    http://riddickbryant.iteye.com/blog/436693

  • 相关阅读:
    动态规划_leetcode416
    动态规划_leetcode377
    基础整理
    super使用简介
    PHP替换指定字符串
    yii安装redis扩展(Windows)
    PHP多维数组去重
    git pull
    vue页面部署并移除url里面的#号
    fatal: refusing to merge unrelated histories(git pull)
  • 原文地址:https://www.cnblogs.com/tonggc1668/p/9469899.html
Copyright © 2011-2022 走看看