import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Properties;
public class App
{
public static void main( String[] args )
{
Properties prop = new Properties();
try {
//set the properties value
prop.setProperty("database", "localhost");
prop.setProperty("dbuser", "Harit");
prop.setProperty("dbpassword", "password");
//save properties to project root folder
prop.store(new FileOutputStream("config.properties"), null);
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
Output: config.properties
#Mon Jan 11 18:54:40 MYT 2013
dbpassword=password
database=localhost
dbuser=harit
0 comments:
Post a Comment