Properties的使用
public static void main(String[] args) {
FileInputStream fis = null;
try {
Properties props = new Properties();
fis = new FileInputStream("jdbc.properties");
props.load(fis); //加载流对应的文件
String name = props.getProperty("name");
String password = props.getProperty("password");
System.out.println("name = " + name + ",password = " + password);
} catch (IOException e) {
e.printStackTrace();
} finally {
if (fis != null) {
try {
fis.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}