package com.test.base.classloader;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.Properties;
import java.util.Set;
import org.junit.Test;
public class TestClassLoader {
@Test
public void testClassLoaderGetProperty() {
String filePath = "/test.properties";
InputStream intpuStream = ClassLoader.class.getResourceAsStream(filePath);
Properties properties = new Properties();
HashMap map = new HashMap();
try {
properties.load(intpuStream);
Set<Entry<Object, Object>> entrySet = properties.entrySet();
for (Entry<Object, Object> entry : entrySet) {
System.out.println(entry.getKey()+ " = " + entry.getValue());
map.put(entry.getKey(), entry.getValue());
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
Java Properties
最新推荐文章于 2021-09-07 21:42:25 发布