hello everyone,
i m new to dotpropertyfile.please help me in this.
How to use dotPropertyfile in java.

thanks in advance.

Recommended Answers

All 2 Replies

http://java.sun.com/j2se/1.5.0/docs/api/java/util/Properties.html

propFile.properties:

promptName = My Name is:
name = Neo

FileInputStream inputStream = new FileInputStream("propFile.properties");

Properties prop = new Properties();
prop.load(inputStream);

String s1 = prop.getProperty("promptName");
String s2 = prop.getProperty("name");

System.out.println(s1 + s2);

In addition to the post #2 of javaAddict, you can use java.util.ResourceBundle class to read properties file.

my.properties

emp.firstname=mr.x
emp.city=abc

Read properties.

ResourceBundle  rb=ResourceBundle("my"); // name of property file
System.out.println(rg.getString("emp.firstname");
...
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.