Saturday 23 November 2013

load properties file in java

Note:-this post is susequent of the "how to store in properties file".
//import the required classes 
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;
 
public class LoadPropShadab
{
    public static void main( String g[] )
    { 
//create the object of Properties class 
 Properties properties = new Properties();
 
     try {
               //use file input stream to get property file
                FileInputStream=new FileInputStream("C:/edu/java/myproptest.properties"); 
                //load the properties file 
                properties.load(f);
                System.out.println(properties.getProperty("userName")); 
                System.out.println(properties.getProperty("password"));
             }  
          catch (IOException e) {
      e.printStackTrace();
        }
 
    }
}
 
Output Screen
 

Contact Me @ www.facebook.com/shdb1,shadab2266@gmail.com