标签:
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.Properties;
/*Properties相当于一个key,value都是String类型的Map。*/
public class PropertyTest {
public static void main(String[] args) throws Exception{
Properties props = new Properties();
props.setProperty("driver", "com.mysql.jdbc.Driver");
props.setProperty("url", "jdbc:mysql://localhost:3306/test");
props.setProperty("username","root");
props.setProperty("password", "123");
props.store(new FileOutputStream("Mysql.ini"), "jdbc");
Properties props2 = new Properties();
props2.setProperty("author", "libin");
props2.load(new FileInputStream("Mysql.ini"));
System.out.println(props2);
}
}
标签:
原文地址:http://www.cnblogs.com/masterlibin/p/4781317.html