`

java读取properties配置文件

    博客分类:
  • java
阅读更多

 


public static void main(String[] arg) {  

Properties props = new Properties(); 

   //读取配置文件 (util.properties放在src目录下 )

   String urlpath = ImageToolDiapose.class.getClassLoader().getResource(("util.properties")).toString().substring(5);

//空格

   String empUrl = urlpath.replace("%20", " ");

   InputStream in = null;

   try {

    in = new BufferedInputStream(new FileInputStream(empUrl));

    props.load(in);

   } catch (FileNotFoundException e1) {

    e1.printStackTrace();

   } catch (IOException e1) {

    e1.printStackTrace();

   }

 System.out.println(props.get("ftpIp")+"="+props.getProperty("ftpPwd"));

}


 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics