首页  :: 新随笔  :: 管理

java读写配置文件

Posted on 2010-07-03 15:14  季枫  阅读(338)  评论(0编辑  收藏  举报
InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("user.properties");   
		   Properties p = new Properties();
		   
		   try {   
		    p.load(inputStream);     
		    String theUserpass=p.getProperty(username);
			   if (theUserpass!=null && theUserpass.equals(password)){
				   return true;
			   }else{
				   return false;
			   }
		   } catch (IOException e1) {   
		    e1.printStackTrace();   
		   }finally{
			   if (inputStream!=null){
				   try {
					inputStream.close();
				} catch (IOException e) {

				}
			   }
		   }
智读 | 成都会领科技有限公司官网 | 智读App下载 | 每天听本书的博客 | |