利用java.util.Properties读取属性文件

利用java.util.Properties读取属性文件

 

1 InputStream inputStream  =   this .getClass().getClassLoader().getResourceAsStream( " ipConfig.properties " );    
2   Properties p  =   new  Properties();    
3    try   {    
4    p.load(inputStream);    
5   }
  catch  (IOException e1)  {    
6    e1.printStackTrace();    
7   }
    
8 System.out.println( " ip: " + p.getProperty( " ip " ) + " ,port: " + p.getProperty( " port " ));  

你可能感兴趣的:(利用java.util.Properties读取属性文件)