java 读取 .properties 文件

 

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" );

 

 

 

你可能感兴趣的:(java 读取 .properties 文件)