public class PropertiesUtils { public static Properties getProperties() { Properties p = new Properties(); try { InputStream inputStream = PropertiesUtils.class.getClassLoader().getResourceAsStream( "/config-file/APIConfig.properties" ); p.load( inputStream ); } catch ( IOException e1 ) { e1.printStackTrace(); } return p; } }
API_SERVER_HOST = api.server.host.com
常量方式调用
public static String API_SERVER_HOST = PropertiesUtils.getProperties().getProperty( "API_SERVER_HOST" );