java读取配置文件

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

你可能感兴趣的:(java)