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

    @ 在项目路径下创建一个text:

       jco.client.ashost=host
       jco.client.client=client

       保存另存为user.properties

    @

    public static void main(String[] args) throws SQLException, IOException {
            String currpath = new File("").getAbsolutePath()                          
                    +"\user.properties";  //获取属性文件的绝对路径
            System.out.println(currpath);
            Properties prop = new Properties();  
            InputStream in;
            try {
                in = new FileInputStream(new File(currpath));//读属性文件
                if(in != null){  
                    prop.load(in);  
                    String ashost = prop.getProperty("jco.client.ashost");  
                    String clientnr = prop.getProperty("jco.client.client");  
                    System.out.println(ashost);
                    System.out.println(clientnr);
                }
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }

        }

  • 相关阅读:
    ES6介绍
    django-缓存
    Python标准模块--functools
    python-深浅拷贝
    Django专题-ugettext_lazy
    PHP 连接 MySQL
    PHP 过滤器
    PHP session
    PHP cookie
    PHP 文件上传
  • 原文地址:https://www.cnblogs.com/zhutouying/p/3139843.html
Copyright © 2011-2022 走看看