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();
            }

        }

  • 相关阅读:
    12-2 mysql 查询
    12-1 mysql的增删改减
    12-1 上午mysql 基本语句
    [题解] [FJOI2016] 建筑师
    [题解] [CF932E] TeamWork
    [题解] [Codechef] CNTDSETS
    [题解] [清华集训 2017] 榕树之心
    [题解] [AGC013D] Piling Up
    [题解] [CQOI2011] 放棋子
    [题解] [ZJOI2017] 仙人掌
  • 原文地址:https://www.cnblogs.com/zhutouying/p/3139843.html
Copyright © 2011-2022 走看看