Java读取配置文件

2017-03-09  本文已影响0人  RageYourDream_
try {
            InputStream in = new BufferedInputStream(new FileInputStream("key.properties"));
            props.load(in);
            for (String it : props.stringPropertyNames()){
                switch (it){
                    case "authkey":this.authkeyAndSecret.setAuthkey(props.getProperty(it));
                        System.out.println("read anthkey.");
                        break;
                    case "secret":this.authkeyAndSecret.setSecret(props.getProperty(it));
                        System.out.println("read secret.");
                        break;
                    case "NodeTreeUrl":this.authkeyAndSecret.setNodeTreeUrl(props.getProperty(it));
                        System.out.println("read secret.");
                        break;
                }
            }
            in.close();
        }catch (Exception e) {
            System.out.println(e);
        }
上一篇 下一篇

猜你喜欢

热点阅读