文章目录
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package com.loogeoustc.test;
import java.io.IOException;
import java.util.Properties;
/**
* @author Emerson
*
* @date 2016年9月2日 下午11:45:09
*/
public class PropertiesTest {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
loadProperties("config.properties");
}
private static void loadProperties(String ConfigFileName) {
Properties configFile = new Properties();
try {
configFile.load(Test.class.getClassLoader().getResourceAsStream(ConfigFileName));
String name = configFile.getProperty("name");
System.out.println(name);
} catch (IOException e) {
// TODO: handle exception
e.printStackTrace();
}
}
}
文章目录