Friday, November 22, 2013

how to write in properties file using java

//needed Class imported here import java.io.FileOutputStream; import java.io.IOException; import java.util.Properties; public class ShadabProp { public static void main( String[] args ) { //create the object of Properties class. Properties properties = new Properties(); try { //set the properties values as (key,values) properties.setProperty("userName", "shadab"); properties.setProperty("password", "123"); FileOutputStream f = new FileOutputStream("C:/edu/java/myproptest.properties"); properties.store(f,null); System.out.println("***Hello data is stored***"); } catch (IOException ex) { ex.printStackTrace(); } } } 
OUTPUT SCREEN:

contact me @ www.facebook.com/shdb1 ,shadab2266@gmail.com