Example & Tutorial understanding programming in easy ways.

How to create and store property file dynamically in java?.

 We can also create property files dynamically. First create Properties object, add all property key-value pair by using setProperty() method. Then write this file to FileOutputStream object to store is as a property file. Below example shows how to create it.


package javatest.files;

import java.io.FileNotFoundException;

import java.io.FileOutputStream;

import java.io.IOException;

import java.io.OutputStream;

import java.util.Properties;

public class PropertyFiletest {

public static void main(String a[]) throws IOException{

OutputStream os = null;

Properties prop = new Properties();

prop.setProperty("name", "hellojava");

prop.setProperty("domain", "wwwr4r.in");

prop.setProperty("email", "r4r@gmail.com");

try {

os = new FileOutputStream("MyProp.properties");

prop.store(os, "Dynamic Property File");

} catch (FileNotFoundException e) {



Read More →
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!