java读写配置文件

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) {

				}
			   }
		   }
原文地址:https://www.cnblogs.com/jifeng/p/1770485.html