Java Code to read from Properties file...

Source : 


import java.io.*;
import java.util.*;

class ReadPropertiesFile {
        public static void main(String[] args) {
                Properties prop = new Properties();
                try {
                        prop.load(new FileInputStream("data.properties"));
                        String name = prop.getProperty("name");
                        String address = prop.getProperty("address");
                        System.out.println("Name: " + name);
                        System.out.println("Address: " + address);
                } catch (Exception e) {
                }
        }
}


Properties File :  data.properties


name=NeethDamera
address=MK Nagar, AP

Execution :


E:\>java ReadPropertiesFile
Name: NeethDamera
Address: MK Nagar, AP


Comments