It is the child class of Hashtable. In this case both key and value should be String Object only.


Properties p = new Properties ()

Important methods of Properties

  1. String getProperty (String name). Return the value associated with the specified Property. If the specified property is not available then we will get null.
  2. String setProperty (String Pname, String Pvalue). If the specified Property is already available then the old value is replaced with new value and old value will be return.
  3. Enumeration PropertyName();
  4. Void load (InputStream in); // to load Properties from properties file to java Properties Object.
  5. void store(outputStream out, String commments) the Properties from java Properties Object to Properties file.


import java.util.Properties;

public class PropertiesDemo {

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		Properties p = new Properties();
		FileInputStream fis = new FileInputStream("/home/narayana/Documents/");
		System.out.println("propety file data:"+p);
		String s = p.getProperty("tutorialName");
		System.out.println("tutorialName parameter value:"+s);
		p.setProperty("Location", "Bangalore");
		FileOutputStream fos = new FileOutputStream("/home/narayana/Documents/");, " updated by Narayanatutorial");
		String loc=p.getProperty("Location");
		System.out.println("Location parameter value:"+loc);



propety file data:{tutorialName=narayanatutorial}
tutorialName parameter value:narayanatutorial
Location parameter value:Bangalore file output

# updated by Narayanatutorial
#Mon Feb 25 05:07:16 IST 2019

Reference Links

The Author


Hello! I am Narayanaswamy founder and admin of I have been working in IT industry more than 7 years. NarayanaTutorial is my web technologies blog. My specialties are Java / J2EE, Spring, Hibernate, Struts, Webservices, PHP, Oracle, MySQL, SQLServer, Web Hosting and Website Development. I am a self learner and passionate about training and writing. I am always trying my best to share my knowledge through my blog.

Leave a Reply