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

    此文章是我工作中遇到读取properties文件的问题,然后写下与大家分享,如果大家有什么问题,欢迎联系我,互相探讨。

    测试类

    package com.test;
    import java.io.IOException;
    import java.io.InputStream;
    import java.text.ParseException;
    import java.util.Properties;

    public class Test {

    /**
    * 读取项目src下的properties文件
    */
    public static void main(String[] args) throws ParseException {
    Properties prop = new Properties();
    InputStream in = Object.class.getResourceAsStream("/stand.properties");
    try {
    prop.load(in);
    String hegestand = (String) prop.get("hegestand");
    String jiyoustand = (String) prop.get("jiyoustand");
    System.out.println("hegestand:"+hegestand+",jiyoustand:"+jiyoustand);
    in.close();
    } catch (IOException e) {
    e.printStackTrace();
    }
    }
    }

    输出:
    hegestand:30000,jiyoustand:60000
    
    

     

     

     

     

     

     

     

    stand.properties文件

    hegestand=30000
    jiyoustand=60000
  • 相关阅读:
    Swift
    Swift
    Swift
    Swift
    Swift
    Swift
    Swift
    C++生产和使用的临时对象
    RecyclerView0基于使用
    Docker创建MySQL集装箱
  • 原文地址:https://www.cnblogs.com/paul-blog/p/7683954.html
Copyright © 2011-2022 走看看