Java中通过java.util.Properties读取配置文件

test.properties配置文件内容如下
switch = xx
log4j.facility = user
logger.facility.level = user.info


Java代码实现如下:
InputStream inputStream = CopyOfTest.class.getClassLoader()
				.getResourceAsStream("com/bright/test.properties");
		Properties osaProperties = new Properties();
		try {
			osaProperties.load(inputStream);
			System.out.println(osaProperties.getProperty("log4j.facility"));
			inputStream.close();
		} catch (IOException e) {
			// TODO do nothing
		}

你可能感兴趣的:(java)