读取properties文件方式

 //src目录下
static Properties pro = new Properties();
            //jar包时用(ide也可以)
//            pro.load(Tool.class.getClassLoader().getResourceAsStream("config.properties"))
//            pro.load(ClassLoader.getSystemClassLoader().getResourceAsStream("config.properties"));

            //IDE用
            pro.load(new FileInputStream(Ftpfile.class.getClassLoader().getResource("config.properties").getPath()));
// 生成文件对象
//            File pf = new File(System.getProperty("user.home") + "/Desktop/config.properties");
//            // 生成文件输入流
//            FileInputStream inpf = null;
//            inpf = new FileInputStream(pf);
//            pro.load(inpf);
View Code

 

posted @ 2016-11-04 15:40  Earic  阅读(212)  评论(0编辑  收藏  举报